public inbox for passt-dev@passt.top
 help / color / mirror / code / Atom feed
* [PATCH v6] tcp: Make pointer const in tcp_revert_seq
@ 2024-06-06  2:03 David Gibson
  2024-06-06  2:41 ` David Gibson
  0 siblings, 1 reply; 2+ messages in thread
From: David Gibson @ 2024-06-06  2:03 UTC (permalink / raw)
  To: passt-dev, Stefano Brivio; +Cc: jmaloy, David Gibson

The th pointer could be const, which causes a cppcheck warning on at least
some cppcheck versions (e.g. Cppcheck 2.13.0 in Fedora 40).

Fixes: e84a01e94 "tcp: move seq_to_tap update to when frame is queued"

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 tcp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tcp.c b/tcp.c
index 89a5b19a..ff1198dd 100644
--- a/tcp.c
+++ b/tcp.c
@@ -1261,8 +1261,8 @@ static void tcp_revert_seq(struct tcp_tap_conn **conns, struct iovec (*frames)[T
 	int i;
 
 	for (i = 0; i < num_frames; i++) {
+		const struct tcphdr *th = frames[i][TCP_IOV_PAYLOAD].iov_base;
 		struct tcp_tap_conn *conn = conns[i];
-		struct tcphdr *th = frames[i][TCP_IOV_PAYLOAD].iov_base;
 		uint32_t seq = ntohl(th->seq);
 
 		if (SEQ_LE(conn->seq_to_tap, seq))
-- 
@@ -1261,8 +1261,8 @@ static void tcp_revert_seq(struct tcp_tap_conn **conns, struct iovec (*frames)[T
 	int i;
 
 	for (i = 0; i < num_frames; i++) {
+		const struct tcphdr *th = frames[i][TCP_IOV_PAYLOAD].iov_base;
 		struct tcp_tap_conn *conn = conns[i];
-		struct tcphdr *th = frames[i][TCP_IOV_PAYLOAD].iov_base;
 		uint32_t seq = ntohl(th->seq);
 
 		if (SEQ_LE(conn->seq_to_tap, seq))
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v6] tcp: Make pointer const in tcp_revert_seq
  2024-06-06  2:03 [PATCH v6] tcp: Make pointer const in tcp_revert_seq David Gibson
@ 2024-06-06  2:41 ` David Gibson
  0 siblings, 0 replies; 2+ messages in thread
From: David Gibson @ 2024-06-06  2:41 UTC (permalink / raw)
  To: passt-dev, Stefano Brivio; +Cc: jmaloy

[-- Attachment #1: Type: text/plain, Size: 1259 bytes --]

On Thu, Jun 06, 2024 at 12:03:05PM +1000, David Gibson wrote:
> The th pointer could be const, which causes a cppcheck warning on at least
> some cppcheck versions (e.g. Cppcheck 2.13.0 in Fedora 40).
> 
> Fixes: e84a01e94 "tcp: move seq_to_tap update to when frame is queued"
> 
> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>

Heh, then I updated and the new cppcheck found some more errors.  I'll
repost this along with the remaining fixes.

> ---
>  tcp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tcp.c b/tcp.c
> index 89a5b19a..ff1198dd 100644
> --- a/tcp.c
> +++ b/tcp.c
> @@ -1261,8 +1261,8 @@ static void tcp_revert_seq(struct tcp_tap_conn **conns, struct iovec (*frames)[T
>  	int i;
>  
>  	for (i = 0; i < num_frames; i++) {
> +		const struct tcphdr *th = frames[i][TCP_IOV_PAYLOAD].iov_base;
>  		struct tcp_tap_conn *conn = conns[i];
> -		struct tcphdr *th = frames[i][TCP_IOV_PAYLOAD].iov_base;
>  		uint32_t seq = ntohl(th->seq);
>  
>  		if (SEQ_LE(conn->seq_to_tap, seq))

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-06-06  3:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-06  2:03 [PATCH v6] tcp: Make pointer const in tcp_revert_seq David Gibson
2024-06-06  2:41 ` David Gibson

Code repositories for project(s) associated with this public inbox

	https://passt.top/passt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for IMAP folder(s).