Bug Summary

File:src/usr.bin/vi/build/../ex/ex_screen.c
Warning:line 111, column 8
Although the value stored to 'len' is used in the enclosing expression, the value is never actually read from 'len'

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 ex_screen.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/vi/build/obj -resource-dir /usr/local/lib/clang/13.0.0 -I /usr/src/usr.bin/vi/build -I /usr/src/usr.bin/vi/build/../include -I . -internal-isystem /usr/local/lib/clang/13.0.0/include -internal-externc-isystem /usr/include -O2 -fdebug-compilation-dir=/usr/src/usr.bin/vi/build/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/vi/build/../ex/ex_screen.c
1/* $OpenBSD: ex_screen.c,v 1.10 2016/01/06 22:28:52 millert Exp $ */
2
3/*-
4 * Copyright (c) 1993, 1994
5 * The Regents of the University of California. All rights reserved.
6 * Copyright (c) 1993, 1994, 1995, 1996
7 * Keith Bostic. All rights reserved.
8 *
9 * See the LICENSE file for redistribution information.
10 */
11
12#include "config.h"
13
14#include <sys/types.h>
15#include <sys/queue.h>
16#include <sys/time.h>
17
18#include <bitstring.h>
19#include <limits.h>
20#include <stdio.h>
21#include <stdlib.h>
22#include <string.h>
23
24#include "../common/common.h"
25#include "../vi/vi.h"
26
27/*
28 * ex_bg -- :bg
29 * Hide the screen.
30 *
31 * PUBLIC: int ex_bg(SCR *, EXCMD *);
32 */
33int
34ex_bg(SCR *sp, EXCMD *cmdp)
35{
36 return (vs_bg(sp));
37}
38
39/*
40 * ex_fg -- :fg [file]
41 * Show the screen.
42 *
43 * PUBLIC: int ex_fg(SCR *, EXCMD *);
44 */
45int
46ex_fg(SCR *sp, EXCMD *cmdp)
47{
48 SCR *nsp;
49 int newscreen;
50
51 newscreen = F_ISSET(cmdp, E_NEWSCREEN)(((cmdp)->flags) & ((0x00000100)));
52 if (vs_fg(sp, &nsp, cmdp->argc ? cmdp->argv[0]->bp : NULL((void *)0), newscreen))
53 return (1);
54
55 /* Set up the switch. */
56 if (newscreen) {
57 sp->nextdisp = nsp;
58 F_SET(sp, SC_SSWITCH)(((sp)->flags) |= ((0x00001000)));
59 }
60 return (0);
61}
62
63/*
64 * ex_resize -- :resize [+-]rows
65 * Change the screen size.
66 *
67 * PUBLIC: int ex_resize(SCR *, EXCMD *);
68 */
69int
70ex_resize(SCR *sp, EXCMD *cmdp)
71{
72 adj_t adj;
73
74 switch (FL_ISSET(cmdp->iflags,((cmdp->iflags) & (0x00004 | 0x00008 | 0x00010))
75 E_C_COUNT | E_C_COUNT_NEG | E_C_COUNT_POS)((cmdp->iflags) & (0x00004 | 0x00008 | 0x00010))) {
76 case E_C_COUNT0x00004:
77 adj = A_SET;
78 break;
79 case E_C_COUNT0x00004 | E_C_COUNT_NEG0x00008:
80 adj = A_DECREASE;
81 break;
82 case E_C_COUNT0x00004 | E_C_COUNT_POS0x00010:
83 adj = A_INCREASE;
84 break;
85 default:
86 ex_emsg(sp, cmdp->cmd->usage, EXM_USAGE);
87 return (1);
88 }
89 return (vs_resize(sp, cmdp->count, adj));
90}
91
92/*
93 * ex_sdisplay --
94 * Display the list of screens.
95 *
96 * PUBLIC: int ex_sdisplay(SCR *);
97 */
98int
99ex_sdisplay(SCR *sp)
100{
101 GS *gp;
102 SCR *tsp;
103 int cnt, col, len, sep;
104
105 gp = sp->gp;
106 if (TAILQ_EMPTY(&gp->hq)(((&gp->hq)->tqh_first) == ((void *)0))) {
107 msgq(sp, M_INFO, "No background screens to display");
108 return (0);
109 }
110
111 col = len = sep = 0;
Although the value stored to 'len' is used in the enclosing expression, the value is never actually read from 'len'
112 cnt = 1;
113 TAILQ_FOREACH(tsp, &gp->hq, q)for((tsp) = ((&gp->hq)->tqh_first); (tsp) != ((void
*)0); (tsp) = ((tsp)->q.tqe_next))
{
114 if (INTERRUPTED(sp)(((((sp)->gp)->flags) & ((0x0004))) || (!v_event_get
((sp), ((void *)0), 0, 0x001) && ((((sp)->gp)->
flags) & ((0x0004)))))
)
115 break;
116 col += len = strlen(tsp->frp->name) + sep;
117 if (col >= sp->cols - 1) {
118 col = len;
119 sep = 0;
120 (void)ex_puts(sp, "\n");
121 } else if (cnt != 1) {
122 sep = 1;
123 (void)ex_puts(sp, " ");
124 }
125 (void)ex_puts(sp, tsp->frp->name);
126 ++cnt;
127 }
128 if (!INTERRUPTED(sp)(((((sp)->gp)->flags) & ((0x0004))) || (!v_event_get
((sp), ((void *)0), 0, 0x001) && ((((sp)->gp)->
flags) & ((0x0004)))))
)
129 (void)ex_puts(sp, "\n");
130 return (0);
131}