Bug Summary

File:src/usr.sbin/mopd/mopchk/mopchk.c
Warning:line 127, column 16
Although the value stored to 'error' is used in the enclosing expression, the value is never actually read from 'error'

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple amd64-unknown-openbsd7.4 -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mopchk.c -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 -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -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/mopd/mopchk/obj -resource-dir /usr/local/llvm16/lib/clang/16 -I /usr/src/usr.sbin/mopd/mopchk -I /usr/src/usr.sbin/mopd/mopchk/.. -I /usr/src/usr.sbin/mopd/mopchk/../common -internal-isystem /usr/local/llvm16/lib/clang/16/include -internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir=/usr/src/usr.sbin/mopd/mopchk/obj -ferror-limit 19 -fwrapv -D_RET_PROTECTOR -ret-protector -fcf-protection=branch -fno-jump-tables -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/scan/2024-01-11-140451-98009-1 -x c /usr/src/usr.sbin/mopd/mopchk/mopchk.c
1/* $OpenBSD: mopchk.c,v 1.21 2023/09/06 11:03:30 jsg Exp $ */
2
3/*
4 * Copyright (c) 1995-96 Mats O Jansson. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26
27/*
28 * mopchk - MOP Check Utility
29 *
30 * Usage: mopchk [-av] [file ...]
31 */
32
33#include "os.h"
34#include "common/common.h"
35#include "common/mopdef.h"
36#include "common/device.h"
37#include "common/pf.h"
38#include "common/file.h"
39
40/*
41 * The list of all interfaces that are being listened to.
42 */
43struct if_info *iflist;
44
45void Usage(void);
46void mopProcess(struct if_info *, u_char *);
47
48int AllFlag = 0; /* listen on "all" interfaces */
49int VersionFlag = 0; /* Show version */
50int promisc = 0; /* promisc mode not needed */
51extern char *__progname;
52extern char version[];
53
54int
55main(int argc, char **argv)
56{
57 struct dllist dl;
58 int op, i;
59 char *filename, *p;
60 struct if_info *ii;
61 int error;
62
63 /* All error reporting is done through syslogs. */
64 openlog(__progname, LOG_PID0x01 | LOG_CONS0x02, LOG_DAEMON(3<<3));
65
66 opterr = 0;
67 while ((op = getopt(argc, argv, "av")) != -1) {
68 switch (op) {
69 case 'a':
70 AllFlag = 1;
71 break;
72 case 'v':
73 VersionFlag = 1;
74 break;
75 default:
76 Usage();
77 /* NOTREACHED */
78 }
79 }
80
81 if (VersionFlag)
82 printf("%s: Version %s\n", __progname, version);
83
84 if (AllFlag) {
85 if (VersionFlag)
86 printf("\n");
87 iflist = NULL((void *)0);
88 deviceInitAll();
89 if (iflist == NULL((void *)0)) {
90 printf("No interface\n");
91 } else {
92 printf("Interface Address\n");
93 p = NULL((void *)0);
94 for (ii = iflist; ii; ii = ii->next) {
95 if (p != NULL((void *)0)) {
96 if (strcmp(p,ii->if_name) == 0)
97 continue;
98 }
99 printf("%-9s %x:%x:%x:%x:%x:%x\n",
100 ii->if_name,
101 ii->eaddr[0],ii->eaddr[1],ii->eaddr[2],
102 ii->eaddr[3],ii->eaddr[4],ii->eaddr[5]);
103 p = ii->if_name;
104 }
105 }
106 }
107
108 if (VersionFlag || AllFlag)
109 i = 1;
110 else
111 i = 0;
112
113 while (argc > optind) {
114 if (i) printf("\n");
115 i++;
116 filename = argv[optind++];
117 printf("Checking: %s\n",filename);
118 dl.ldfd = open(filename, O_RDONLY0x0000);
119 if (dl.ldfd == -1) {
120 printf("Unknown file.\n");
121 } else {
122 if ((error = CheckElfFile(dl.ldfd)) == 0) {
123 if (GetElf32FileInfo(&dl, INFO_PRINT1) < 0 &&
124 GetElf64FileInfo(&dl, INFO_PRINT1) < 0) {
125 printf("Some failure in GetElfXXFileInfo\n");
126 }
127 } else if ((error = CheckAOutFile(dl.ldfd)) == 0) {
Although the value stored to 'error' is used in the enclosing expression, the value is never actually read from 'error'
128 if (GetAOutFileInfo(&dl, INFO_PRINT1) < 0) {
129 printf("Some failure in GetAOutFileInfo\n");
130 }
131 } else if ((error = CheckMopFile(dl.ldfd)) == 0) {
132 if (GetMopFileInfo(&dl, INFO_PRINT1) < 0) {
133 printf("Some failure in GetMopFileInfo\n");
134 }
135 };
136 }
137 (void)close(dl.ldfd);
138 }
139 return 0;
140}
141
142void
143Usage(void)
144{
145 fprintf(stderr(&__sF[2]), "usage: %s [-av] [file ...]\n", __progname);
146 exit(1);
147}
148
149/*
150 * Process incoming packages, NOT.
151 */
152void
153mopProcess(struct if_info *ii, u_char *pkt)
154{
155}
156