]> The Tcpdump Group git mirrors - libpcap/commitdiff
Throw in a cast to squelch a warning.
authorGuy Harris <[email protected]>
Thu, 22 Nov 2018 21:34:31 +0000 (13:34 -0800)
committerGuy Harris <[email protected]>
Thu, 22 Nov 2018 21:34:31 +0000 (13:34 -0800)
And throw in a comment to explain why the cast is safe.

optimize.c

index f1e9f2a4f0f784e4d512bd4be9f7b986a47ce2ff..e676df9fe8227fae740c671075b8bd6da994a877 100644 (file)
@@ -520,8 +520,12 @@ atomuse(struct stmt *s)
 
        case BPF_LD:
        case BPF_LDX:
+               /*
+                * As there are fewer than 2^31 memory locations,
+                * s->k should be convertable to int without problems.
+                */
                return (BPF_MODE(c) == BPF_IND) ? X_ATOM :
-                       (BPF_MODE(c) == BPF_MEM) ? s->k : -1;
+                       (BPF_MODE(c) == BPF_MEM) ? (int)s->k : -1;
 
        case BPF_ST:
                return A_ATOM;