Bug Summary

File:got/../lib/diff_output_plain.c
Warning:line 64, column 7
Branch condition evaluates to a garbage value

Annotated Source Code

Press '?' to see keyboard shortcuts

clang -cc1 -cc1 -triple amd64-unknown-openbsd6.9 -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name diff_output_plain.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 -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /usr/local/lib/clang/11.1.0 -I /home/ben/Projects/got/got/../include -I /home/ben/Projects/got/got/../lib -D GOT_LIBEXECDIR=/home/ben/bin -D GOT_VERSION=0.53-current -internal-isystem /usr/local/lib/clang/11.1.0/include -internal-externc-isystem /usr/include -O0 -fdebug-compilation-dir /home/ben/Projects/got/got/obj -ferror-limit 19 -fwrapv -D_RET_PROTECTOR -ret-protector -fgnuc-version=4.2.1 -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 -o /home/ben/Projects/got/scan/2021-05-28-230913-68537-1 -x c /home/ben/Projects/got/got/../lib/diff_output_plain.c
1/* Output all lines of a diff_result. */
2/*
3 * Copyright (c) 2020 Neels Hofmeyr <neels@hofmeyr.de>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#include <errno(*__errno()).h>
19#include <stdint.h>
20#include <stdio.h>
21#include <stdbool.h>
22#include <stdlib.h>
23
24#include <arraylist.h>
25#include <diff_main.h>
26#include <diff_output.h>
27
28#include "diff_internal.h"
29
30int
31diff_output_plain(struct diff_output_info **output_info, FILE *dest,
32 const struct diff_input_info *info,
33 const struct diff_result *result)
34{
35 struct diff_output_info *outinfo = NULL((void *)0);
36 int i, rc;
1
'rc' declared without an initial value
37
38 if (!result)
2
Assuming 'result' is non-null
3
Taking false branch
39 return EINVAL22;
40 if (result->rc != DIFF_RC_OK0)
4
Assuming field 'rc' is equal to DIFF_RC_OK
5
Taking false branch
41 return result->rc;
42
43 if (output_info) {
6
Assuming 'output_info' is null
7
Taking false branch
44 *output_info = diff_output_info_alloc();
45 if (*output_info == NULL((void *)0))
46 return errno(*__errno());
47 outinfo = *output_info;
48 }
49
50 for (i = 0; i < result->chunks.len; i++) {
8
Assuming 'i' is < field 'len'
9
Loop condition is true. Entering loop body
51 struct diff_chunk *c = &result->chunks.head[i];
52 if (c->left_count && c->right_count)
10
Assuming field 'left_count' is 0
53 rc = diff_output_lines(outinfo, dest,
54 c->solved ? " " : "?",
55 c->left_start, c->left_count);
56 else if (c->left_count
10.1
Field 'left_count' is 0
&& !c->right_count)
57 rc = diff_output_lines(outinfo, dest,
58 c->solved ? "-" : "?",
59 c->left_start, c->left_count);
60 else if (c->right_count && !c->left_count)
11
Assuming field 'right_count' is 0
61 rc = diff_output_lines(outinfo, dest,
62 c->solved ? "+" : "?",
63 c->right_start, c->right_count);
64 if (rc)
12
Branch condition evaluates to a garbage value
65 return rc;
66 }
67 return DIFF_RC_OK0;
68}