Bug Summary

File:src/games/pig/pig.c
Warning:line 59, 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 pig.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/games/pig/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/games/pig/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/games/pig/pig.c
1/* $OpenBSD: pig.c,v 1.17 2016/03/07 12:07:56 mestre Exp $ */
2/* $NetBSD: pig.c,v 1.2 1995/03/23 08:41:40 cgd Exp $ */
3
4/*-
5 * Copyright (c) 1992, 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 <ctype.h>
34#include <err.h>
35#include <stdio.h>
36#include <stdlib.h>
37#include <string.h>
38#include <unistd.h>
39
40void pigout(char *, int);
41__dead__attribute__((__noreturn__)) void usage(void);
42
43int
44main(int argc, char *argv[])
45{
46 int len;
47 int ch;
48 char buf[1024];
49
50 if (pledge("stdio", NULL((void *)0)) == -1)
51 err(1, "pledge");
52
53 while ((ch = getopt(argc, argv, "h")) != -1)
54 switch(ch) {
55 case 'h':
56 default:
57 usage();
58 }
59 argc -= optind;
Value stored to 'argc' is never read
60 argv += optind;
61
62 for (len = 0; (ch = getchar()(!__isthreaded ? (--((&__sF[0]))->_r < 0 ? __srget(
(&__sF[0])) : (int)(*((&__sF[0]))->_p++)) : (getc)
((&__sF[0])))
) != EOF(-1);) {
63 if (isalpha(ch)) {
64 if (len >= sizeof(buf))
65 errx(1, "ate too much!");
66 buf[len++] = ch;
67 continue;
68 }
69 if (len != 0) {
70 pigout(buf, len);
71 len = 0;
72 }
73 (void)putchar(ch)(!__isthreaded ? __sputc(ch, (&__sF[1])) : (putc)(ch, (&
__sF[1])))
;
74 }
75 return 0;
76}
77
78void
79pigout(char *buf, int len)
80{
81 int ch, start, i;
82 int olen, allupper, firstupper;
83
84 /* See if the word is all upper case */
85 allupper = firstupper = isupper((unsigned char)buf[0]);
86 for (i = 1; i < len && allupper; i++)
87 allupper = allupper && isupper((unsigned char)buf[i]);
88
89 /*
90 * If the word starts with a vowel, append "way". Don't treat 'y'
91 * as a vowel if it appears first.
92 */
93 if (strchr("aeiouAEIOU", buf[0]) != NULL((void *)0)) {
94 (void)printf("%.*s%s", len, buf,
95 allupper ? "WAY" : "way");
96 return;
97 }
98
99 /*
100 * Copy leading consonants to the end of the word. The unit "qu"
101 * isn't treated as a vowel.
102 */
103 if (!allupper)
104 buf[0] = tolower((unsigned char)buf[0]);
105 for (start = 0, olen = len;
106 !strchr("aeiouyAEIOUY", buf[start]) && start < olen;) {
107 ch = buf[len++] = buf[start++];
108 if ((ch == 'q' || ch == 'Q') && start < olen &&
109 (buf[start] == 'u' || buf[start] == 'U'))
110 buf[len++] = buf[start++];
111 }
112 if (firstupper)
113 buf[start] = toupper((unsigned char)buf[start]);
114 (void)printf("%.*s%s", olen, buf + start, allupper ? "AY" : "ay");
115}
116
117void
118usage(void)
119{
120 (void)fprintf(stderr(&__sF[2]), "usage: %s\n", getprogname());
121 exit(1);
122}