Bug Summary

File:src/usr.bin/vis/vis.c
Warning:line 109, column 2
Value stored to 'argc' 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 vis.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.bin/vis/obj -resource-dir /usr/local/lib/clang/13.0.0 -internal-isystem /usr/local/lib/clang/13.0.0/include -internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir=/usr/src/usr.bin/vis/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.bin/vis/vis.c
1/* $OpenBSD: vis.c,v 1.21 2020/08/03 01:08:37 deraadt Exp $ */
2/* $NetBSD: vis.c,v 1.4 1994/12/20 16:13:03 jtc Exp $ */
3
4/*-
5 * Copyright (c) 1989, 1993
6 * The Regents of the University of California. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of the University nor the names of its contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33#include <stdio.h>
34#include <string.h>
35#include <stdlib.h>
36#include <unistd.h>
37#include <limits.h>
38#include <err.h>
39#include <vis.h>
40
41int eflags, fold, foldwidth=80, none, markeol;
42
43#ifdef DEBUG
44int debug;
45#endif
46
47int foldit(char *, int, int);
48void process(FILE *);
49__dead__attribute__((__noreturn__)) void usage(void);
50
51int
52main(int argc, char *argv[])
53{
54 const char *errstr;
55 FILE *fp;
56 int ch;
57
58 if (pledge("stdio rpath", NULL((void *)0)) == -1)
59 err(1, "pledge");
60
61 while ((ch = getopt(argc, argv, "anwctsobfF:ld")) != -1)
62 switch(ch) {
63 case 'a':
64 eflags |= VIS_ALL0x400;
65 break;
66 case 'n':
67 none = 1;
68 break;
69 case 'w':
70 eflags |= VIS_WHITE(0x04 | 0x08 | 0x10);
71 break;
72 case 'c':
73 eflags |= VIS_CSTYLE0x02;
74 break;
75 case 't':
76 eflags |= VIS_TAB0x08;
77 break;
78 case 's':
79 eflags |= VIS_SAFE0x20;
80 break;
81 case 'o':
82 eflags |= VIS_OCTAL0x01;
83 break;
84 case 'b':
85 eflags |= VIS_NOSLASH0x40;
86 break;
87 case 'F':
88 foldwidth = strtonum(optarg, 1, INT_MAX2147483647, &errstr);
89 if (errstr)
90 errx(1, "%s: %s", optarg, errstr);
91 if (foldwidth < 5)
92 errx(1, "can't fold lines to less than 5 cols");
93 /*FALLTHROUGH*/
94 case 'f':
95 fold = 1; /* fold output lines to 80 cols */
96 break; /* using hidden newline */
97 case 'l':
98 markeol = 1; /* mark end of line with \$ */
99 break;
100#ifdef DEBUG
101 case 'd':
102 debug = 1;
103 break;
104#endif
105 case '?':
106 default:
107 usage();
108 }
109 argc -= optind;
Value stored to 'argc' is never read
110 argv += optind;
111
112 if (*argv)
113 while (*argv) {
114 if ((fp=fopen(*argv, "r")) != NULL((void *)0)) {
115 process(fp);
116 fclose(fp);
117 } else
118 warn("%s", *argv);
119 argv++;
120 }
121 else {
122 if (pledge("stdio", NULL((void *)0)) == -1)
123 err(1, "pledge");
124 process(stdin(&__sF[0]));
125 }
126 exit(0);
127}
128
129void
130process(FILE *fp)
131{
132 static int col = 0;
133 char *cp = "\0";
134 int c, rachar;
135 char buff[5];
136
137 cp++; /* so *(cp-1) starts out != '\n' */
138 c = getc(fp)(!__isthreaded ? (--(fp)->_r < 0 ? __srget(fp) : (int)(
*(fp)->_p++)) : (getc)(fp))
;
139 while (c != EOF(-1)) {
140 rachar = getc(fp)(!__isthreaded ? (--(fp)->_r < 0 ? __srget(fp) : (int)(
*(fp)->_p++)) : (getc)(fp))
;
141 if (none) {
142 cp = buff;
143 *cp++ = c;
144 if (c == '\\')
145 *cp++ = '\\';
146 *cp = '\0';
147 } else if (markeol && c == '\n') {
148 cp = buff;
149 if ((eflags & VIS_NOSLASH0x40) == 0)
150 *cp++ = '\\';
151 *cp++ = '$';
152 *cp++ = '\n';
153 *cp = '\0';
154 } else
155 (void) vis(buff, (char)c, eflags, (char)rachar);
156
157 cp = buff;
158 if (fold) {
159#ifdef DEBUG
160 if (debug)
161 printf("<%02d,", col);
162#endif
163 col = foldit(cp, col, foldwidth);
164#ifdef DEBUG
165 if (debug)
166 printf("%02d>", col);
167#endif
168 }
169 do {
170 putchar(*cp)(!__isthreaded ? __sputc(*cp, (&__sF[1])) : (putc)(*cp, (
&__sF[1])))
;
171 } while (*++cp);
172 c = rachar;
173 }
174 /*
175 * terminate partial line with a hidden newline
176 */
177 if (fold && *(cp-1) != '\n')
178 printf("\\\n");
179}
180
181__dead__attribute__((__noreturn__)) void
182usage(void)
183{
184 extern char *__progname;
185
186 fprintf(stderr(&__sF[2]), "usage: %s [-abcflnostw] [-F foldwidth] [file ...]\n",
187 __progname);
188 exit(1);
189}