Blame SOURCES/fstrm-0.6.1-Fix-CLANG_WARNING.patch

ebc050
From abefc739f769a8c9bd89db78b9a3e9dd9e366064 Mon Sep 17 00:00:00 2001
ebc050
From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= <pemensik@redhat.com>
ebc050
Date: Mon, 11 Jan 2021 12:25:27 +0100
ebc050
Subject: [PATCH] Fix CLANG_WARNING
ebc050
ebc050
libmy/argv.c:1352:7: warning[core.uninitialized.Assign]: The expression is an uninitialized value. The computed value will also be garbage
ebc050
      (*(int *)var)++;
ebc050
      ^~~~~~~~~~~~~
ebc050
libmy/argv.c:1207:29: note: Assuming field 'at_value' is not equal to 0
ebc050
  for (type_p = argv_types; type_p->at_value != 0; type_p++) {
ebc050
                            ^~~~~~~~~~~~~~~~~~~~~
ebc050
libmy/argv.c:1207:3: note: Loop condition is true.  Entering loop body
ebc050
  for (type_p = argv_types; type_p->at_value != 0; type_p++) {
ebc050
  ^
ebc050
libmy/argv.c:1208:9: note: Assuming 'val_type' is equal to field 'at_value'
ebc050
    if (type_p->at_value == val_type) {
ebc050
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
ebc050
libmy/argv.c:1208:5: note: Taking true branch
ebc050
    if (type_p->at_value == val_type) {
ebc050
    ^
ebc050
libmy/argv.c:1210:7: note:  Execution continues on line 1214
ebc050
      break;
ebc050
      ^
ebc050
libmy/argv.c:1214:15: note: Field 'at_value' is not equal to 0
ebc050
  if (type_p->at_value == 0) {
ebc050
              ^
ebc050
libmy/argv.c:1214:3: note: Taking false branch
ebc050
  if (type_p->at_value == 0) {
ebc050
  ^
ebc050
libmy/argv.c:1222:7: note: Assuming the condition is true
ebc050
  if (type & ARGV_FLAG_ARRAY) {
ebc050
      ^~~~~~~~~~~~~~~~~~~~~~
ebc050
libmy/argv.c:1222:3: note: Taking true branch
ebc050
  if (type & ARGV_FLAG_ARRAY) {
ebc050
  ^
ebc050
libmy/argv.c:1225:9: note: Assuming field 'aa_entry_n' is equal to 0
ebc050
    if (arr_p->aa_entry_n == 0) {
ebc050
        ^~~~~~~~~~~~~~~~~~~~~~
ebc050
libmy/argv.c:1225:5: note: Taking true branch
ebc050
    if (arr_p->aa_entry_n == 0) {
ebc050
    ^
ebc050
libmy/argv.c:1226:35: note: Storing uninitialized value
ebc050
      arr_p->aa_entries = (char *)malloc(ARRAY_INCR *size);
ebc050
                                  ^~~~~~~~~~~~~~~~~~~~~~~~
ebc050
libmy/argv.c:1234:9: note: Assuming field 'aa_entries' is not equal to NULL
ebc050
    if (arr_p->aa_entries == NULL) {
ebc050
        ^~~~~~~~~~~~~~~~~~~~~~~~~
ebc050
libmy/argv.c:1234:5: note: Taking false branch
ebc050
    if (arr_p->aa_entries == NULL) {
ebc050
    ^
ebc050
libmy/argv.c:1251:3: note: Control jumps to 'case 17:'  at line 1349
ebc050
  switch (val_type) {
ebc050
  ^
ebc050
libmy/argv.c:1351:9: note: Assuming 'arg' is equal to NULL
ebc050
    if (arg == NULL) {
ebc050
        ^~~~~~~~~~~
ebc050
libmy/argv.c:1351:5: note: Taking true branch
ebc050
    if (arg == NULL) {
ebc050
    ^
ebc050
libmy/argv.c:1352:7: note: The expression is an uninitialized value. The computed value will also be garbage
ebc050
      (*(int *)var)++;
ebc050
      ^~~~~~~~~~~~~
ebc050
---
ebc050
 libmy/argv.c | 5 ++++-
ebc050
 1 file changed, 4 insertions(+), 1 deletion(-)
ebc050
ebc050
diff --git a/libmy/argv.c b/libmy/argv.c
ebc050
index 0b28026..547065c 100644
ebc050
--- a/libmy/argv.c
ebc050
+++ b/libmy/argv.c
ebc050
@@ -1223,12 +1223,15 @@ static	int	string_to_value(const char *arg, ARGV_PNT var,
ebc050
     arr_p = (argv_array_t *)var;
ebc050
     
ebc050
     if (arr_p->aa_entry_n == 0) {
ebc050
-      arr_p->aa_entries = (char *)malloc(ARRAY_INCR *size);
ebc050
+      arr_p->aa_entries = (char *)calloc(ARRAY_INCR, size);
ebc050
     }
ebc050
     else if (arr_p->aa_entry_n % ARRAY_INCR == 0) {
ebc050
       arr_p->aa_entries =
ebc050
 	(char *)realloc(arr_p->aa_entries, (arr_p->aa_entry_n + ARRAY_INCR) *
ebc050
 			size);
ebc050
+      if (arr_p->aa_entries != NULL)
ebc050
+	memset((char *)(arr_p->aa_entries) + arr_p->aa_entry_n * size, 0,
ebc050
+	       ARRAY_INCR*size);
ebc050
     }
ebc050
     
ebc050
     if (arr_p->aa_entries == NULL) {
ebc050
-- 
ebc050
2.26.3
ebc050