Bug Summary

File:src/usr.sbin/tcpdump/print-ripng.c
Warning:line 83, column 3
Value stored to 'trunc' is never read

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple amd64-unknown-openbsd7.0 -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name print-ripng.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 1 -pic-is-pie -mframe-pointer=all -relaxed-aliasing -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-feature +retpoline-indirect-calls -target-feature +retpoline-indirect-branches -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/usr/src/usr.sbin/tcpdump/obj -resource-dir /usr/local/lib/clang/13.0.0 -I /usr/src/usr.sbin/tcpdump/../../sbin/pfctl -I /usr/src/usr.sbin/tcpdump/../hostapd -I /usr/src/usr.sbin/tcpdump/../../lib/libpcap -D CSLIP -D PPP -D HAVE_FDDI -D ETHER_SERVICE -D HAVE_ETHER_NTOHOST -D INET6 -I /usr/src/usr.sbin/tcpdump/../../sbin/pfctl -D FAKE_PF_KERNEL -internal-isystem /usr/local/lib/clang/13.0.0/include -internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir=/usr/src/usr.sbin/tcpdump/obj -ferror-limit 19 -fwrapv -D_RET_PROTECTOR -ret-protector -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-valloc -fno-builtin-free -fno-builtin-strdup -fno-builtin-strndup -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /home/ben/Projects/vmm/scan-build/2022-01-12-194120-40624-1 -x c /usr/src/usr.sbin/tcpdump/print-ripng.c
1/* $OpenBSD: print-ripng.c,v 1.7 2018/10/22 16:12:45 kn Exp $ */
2
3/*
4 * Copyright (c) 1989, 1990, 1991, 1993, 1994
5 * The Regents of the University of California. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that: (1) source code distributions
9 * retain the above copyright notice and this paragraph in its entirety, (2)
10 * distributions including binary code include the above copyright notice and
11 * this paragraph in its entirety in the documentation or other materials
12 * provided with the distribution, and (3) all advertising materials mentioning
13 * features or use of this software display the following acknowledgement:
14 * ``This product includes software developed by the University of California,
15 * Lawrence Berkeley Laboratory and its contributors.'' Neither the name of
16 * the University nor the names of its contributors may be used to endorse
17 * or promote products derived from this software without specific prior
18 * written permission.
19 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
20 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
21 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
22 */
23
24#include <sys/time.h>
25#include <sys/types.h>
26#include <sys/socket.h>
27
28#include <netinet/in.h>
29#include <netinet/ip.h>
30#include <netinet/ip_var.h>
31#include <netinet/udp.h>
32#include <netinet/udp_var.h>
33
34#include <errno(*__errno()).h>
35#include <stdio.h>
36
37#include <netinet/ip6.h>
38
39#include "route6d.h"
40#include "interface.h"
41#include "addrtoname.h"
42
43static int
44rip6_entry_print(const struct netinfo6 *ni, int metric)
45{
46 int l;
47 l = printf("%s/%d", ip6addr_string(&ni->rip6_dest)getname6((const u_char *)(&ni->rip6_dest)), ni->rip6_plen);
48 if (ni->rip6_tag)
49 l += printf(" [%d]", ntohs(ni->rip6_tag)(__uint16_t)(__builtin_constant_p(ni->rip6_tag) ? (__uint16_t
)(((__uint16_t)(ni->rip6_tag) & 0xffU) << 8 | ((
__uint16_t)(ni->rip6_tag) & 0xff00U) >> 8) : __swap16md
(ni->rip6_tag))
);
50 if (metric)
51 l += printf(" (%d)", ni->rip6_metric);
52 return l;
53}
54
55void
56ripng_print(const u_char *dat, int length)
57{
58 const struct rip6 *rp = (struct rip6 *)dat;
59 const struct netinfo6 *ni;
60 int amt = snapend - dat;
61 int i = min(length, amt)((length)>(amt)?(amt):(length)) -
62 (sizeof(struct rip6) - sizeof(struct netinfo6));
63 int j;
64 int trunc;
65
66 if (i < 0)
67 return;
68
69 switch (rp->rip6_cmd) {
70
71 case RIP6_REQUEST1:
72 j = length / sizeof(*ni);
73 if (j == 1
74 && rp->rip6_netsrip6un.ru6_nets->rip6_metric == HOPCNT_INFINITY616
75 && IN6_IS_ADDR_UNSPECIFIED(&rp->rip6_nets->rip6_dest)((*(const u_int32_t *)(const void *)(&(&rp->rip6un
.ru6_nets->rip6_dest)->__u6_addr.__u6_addr8[0]) == 0) &&
(*(const u_int32_t *)(const void *)(&(&rp->rip6un
.ru6_nets->rip6_dest)->__u6_addr.__u6_addr8[4]) == 0) &&
(*(const u_int32_t *)(const void *)(&(&rp->rip6un
.ru6_nets->rip6_dest)->__u6_addr.__u6_addr8[8]) == 0) &&
(*(const u_int32_t *)(const void *)(&(&rp->rip6un
.ru6_nets->rip6_dest)->__u6_addr.__u6_addr8[12]) == 0))
) {
76 printf("ripng-req dump");
77 break;
78 }
79 if (j * sizeof(*ni) != length - 4)
80 printf("ripng-req %d[%d]:", j, length);
81 else
82 printf("ripng-req %d:", j);
83 trunc = ((i / sizeof(*ni)) * sizeof(*ni) != i);
Value stored to 'trunc' is never read
84 for (ni = rp->rip6_netsrip6un.ru6_nets; (i -= sizeof(*ni)) >= 0; ++ni) {
85 if (vflag)
86 printf("\n\t");
87 else
88 printf(" ");
89 rip6_entry_print(ni, 0);
90 }
91 break;
92 case RIP6_RESPONSE2:
93 j = length / sizeof(*ni);
94 if (j * sizeof(*ni) != length - 4)
95 printf("ripng-resp %d[%d]:", j, length);
96 else
97 printf("ripng-resp %d:", j);
98 trunc = ((i / sizeof(*ni)) * sizeof(*ni) != i);
99 for (ni = rp->rip6_netsrip6un.ru6_nets; (i -= sizeof(*ni)) >= 0; ++ni) {
100 if (vflag)
101 printf("\n\t");
102 else
103 printf(" ");
104 rip6_entry_print(ni, ni->rip6_metric);
105 }
106 if (trunc)
107 printf("[|rip]");
108 break;
109 default:
110 printf("ripng-%d ?? %d", rp->rip6_cmd, length);
111 break;
112 }
113 if (rp->rip6_vers != RIP6_VERSION1)
114 printf(" [vers %d]", rp->rip6_vers);
115}