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

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