Bug Summary

File:src/usr.bin/vi/build/../vi/v_delete.c
Warning:line 71, column 7
2nd function call argument is an uninitialized value

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 v_delete.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/../vi/v_delete.c
1/* $OpenBSD: v_delete.c,v 1.8 2014/11/12 04:28:41 bentley Exp $ */
2
3/*-
4 * Copyright (c) 1992, 1993, 1994
5 * The Regents of the University of California. All rights reserved.
6 * Copyright (c) 1992, 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
22#include "../common/common.h"
23#include "vi.h"
24
25/*
26 * v_delete -- [buffer][count]d[count]motion
27 * [buffer][count]D
28 * Delete a range of text.
29 *
30 * PUBLIC: int v_delete(SCR *, VICMD *);
31 */
32int
33v_delete(SCR *sp, VICMD *vp)
34{
35 recno_t nlines;
1
'nlines' declared without an initial value
36 size_t len;
37 int lmode;
38
39 lmode = F_ISSET(vp, VM_LMODE)(((vp)->flags) & ((0x00000008))) ? CUT_LINEMODE0x01 : 0;
2
Assuming the condition is false
3
'?' condition is false
40
41 /* Yank the lines. */
42 if (cut(sp, F_ISSET(vp, VC_BUFFER)(((vp)->flags) & ((0x00000200))) ? &vp->buffer : NULL((void *)0),
4
Assuming the condition is false
5
'?' condition is false
8
Assuming the condition is false
9
Taking false branch
43 &vp->m_start, &vp->m_stop,
44 lmode | (F_ISSET(vp, VM_CUTREQ)(((vp)->flags) & ((0x00000002))) ? CUT_NUMREQ0x04 : CUT_NUMOPT0x02)))
6
Assuming the condition is false
7
'?' condition is false
45 return (1);
46
47 /* Delete the lines. */
48 if (del(sp, &vp->m_start, &vp->m_stop, lmode))
10
Assuming the condition is false
11
Taking false branch
49 return (1);
50
51 /*
52 * Check for deletion of the entire file. Try to check a close
53 * by line so we don't go to the end of the file unnecessarily.
54 */
55 if (!db_exist(sp, vp->m_final.lno + 1)) {
12
Assuming the condition is false
13
Taking false branch
56 if (db_last(sp, &nlines))
57 return (1);
58 if (nlines == 0) {
59 vp->m_final.lno = 1;
60 vp->m_final.cno = 0;
61 return (0);
62 }
63 }
64
65 /*
66 * One special correction, in case we've deleted the current line or
67 * character. We check it here instead of checking in every command
68 * that can be a motion component.
69 */
70 if (db_get(sp, vp->m_final.lno, 0, NULL((void *)0), &len)) {
14
Assuming the condition is true
15
Taking true branch
71 if (db_get(sp, nlines, DBG_FATAL0x001, NULL((void *)0), &len))
16
2nd function call argument is an uninitialized value
72 return (1);
73 vp->m_final.lno = nlines;
74 }
75
76 /*
77 * !!!
78 * Cursor movements, other than those caused by a line mode command
79 * moving to another line, historically reset the relative position.
80 *
81 * This currently matches the check made in v_yank(), I'm hoping that
82 * they should be consistent...
83 */
84 if (!F_ISSET(vp, VM_LMODE)(((vp)->flags) & ((0x00000008)))) {
85 F_CLR(vp, VM_RCM_MASK)(((vp)->flags) &= ~((0x000001f0)));
86 F_SET(vp, VM_RCM_SET)(((vp)->flags) |= ((0x00000020)));
87
88 /* Make sure the set cursor position exists. */
89 if (vp->m_final.cno >= len)
90 vp->m_final.cno = len ? len - 1 : 0;
91 }
92
93 /*
94 * !!!
95 * The "dd" command moved to the first non-blank; "d<motion>"
96 * didn't.
97 */
98 if (F_ISSET(vp, VM_LDOUBLE)(((vp)->flags) & ((0x00000004)))) {
99 F_CLR(vp, VM_RCM_MASK)(((vp)->flags) &= ~((0x000001f0)));
100 F_SET(vp, VM_RCM_SETFNB)(((vp)->flags) |= ((0x00000040)));
101 }
102 return (0);
103}