fix analyzer use of uninitialized char variable's value #3

Merged
dalmurii merged 1 commit from kenter7317/aclspv:master into master 2026-05-08 13:51:59 +00:00
Contributor

Summerized Information

there is some analyzer use of uninitialized char variable's value, i find it since when i test under the below environment. then i initialized those value with '\0'

Environment

OS: Window 11 Education Edition 25h2
Complier: Clang 22.1.4
IDE : CLion 2026 1.1 (261.23567.135)
Generator : Ninja 1.21.1

The Corresponding error message

In file included from C:/Users/kenter7317/Desktop/Project/Clion/test/aclspv/lib/emit/count_fn.c:6:
C:/Users/kenter7317/Desktop/Project/Clion/test/aclspv/lib/attr/wrkgroup.h: In function 'aclattr_wrkgroup':
C:/Users/kenter7317/Desktop/Project/Clion/test/aclspv/lib/attr/wrkgroup.h:34:81: error: use of uninitialized value 'F1' [CWE-457] [-Werror=analyzer-use-of-uninitialized-value]
   34 |                 RETDATA->m_flag_specid = (unsigned)(F0 == '&') | (unsigned)((F1 == '&') << 1) | (unsigned)((F2 == '&') << 2);
      |                                                                             ~~~~^~~~~~~
  'aclattr_wrkgroup': events 1-5
    |
    |   25 |         if ((NIDDLE = strstr(ATTR_KIND.data, "aclspv_wrkgroup_size_id"))) {
    |      |            ~                         
    |      |            |
    |      |            (3) following 'true' branch (when 'NIDDLE' is non-NULL)...
    |   26 |                 char            F0, F1, F2 = 0;
    |      |                 ~~~~                ^~
    |      |                 |                   |
    |      |                 |                   (1) region created on stack here
    |      |                 |                   (2) capacity: 1 byte
    |      |                 (4) ...to here
    |......
    |   34 |                 RETDATA->m_flag_specid = (unsigned)(F0 == '&') | (unsigned)((F1 == '&') << 1) | (unsigned)((F2 == '&') << 2);
    |      |                                                                             ~~~~~~~~~~~
    |      |                                                                                 |
    |      |                                                                                 (5) use of uninitialized value 'F1' here
    |

Changes

in project-root/lib/attr/wrkgroup.h
origin

26 |  char F0, F1, F2; // formatting is deleted for better readability

in fix commit

4 |  #define ZERO = '\0' // Magic Number 0 Macro is added.
.
.
.
26+1 (27) | char F0 = '\0', F1 = '\0', F2 = '\0';

i don't know specific kinds of solution about this problem, then i initialize those variable '\0'

### Summerized Information there is some analyzer use of uninitialized char variable's value, i find it since when i test under the below environment. then i initialized those value with '\0' ### Environment ``` OS: Window 11 Education Edition 25h2 Complier: Clang 22.1.4 IDE : CLion 2026 1.1 (261.23567.135) Generator : Ninja 1.21.1 ``` ### The Corresponding error message ``` In file included from C:/Users/kenter7317/Desktop/Project/Clion/test/aclspv/lib/emit/count_fn.c:6: C:/Users/kenter7317/Desktop/Project/Clion/test/aclspv/lib/attr/wrkgroup.h: In function 'aclattr_wrkgroup': C:/Users/kenter7317/Desktop/Project/Clion/test/aclspv/lib/attr/wrkgroup.h:34:81: error: use of uninitialized value 'F1' [CWE-457] [-Werror=analyzer-use-of-uninitialized-value] 34 | RETDATA->m_flag_specid = (unsigned)(F0 == '&') | (unsigned)((F1 == '&') << 1) | (unsigned)((F2 == '&') << 2); | ~~~~^~~~~~~ 'aclattr_wrkgroup': events 1-5 | | 25 | if ((NIDDLE = strstr(ATTR_KIND.data, "aclspv_wrkgroup_size_id"))) { | | ~ | | | | | (3) following 'true' branch (when 'NIDDLE' is non-NULL)... | 26 | char F0, F1, F2 = 0; | | ~~~~ ^~ | | | | | | | (1) region created on stack here | | | (2) capacity: 1 byte | | (4) ...to here |...... | 34 | RETDATA->m_flag_specid = (unsigned)(F0 == '&') | (unsigned)((F1 == '&') << 1) | (unsigned)((F2 == '&') << 2); | | ~~~~~~~~~~~ | | | | | (5) use of uninitialized value 'F1' here | ``` ### Changes **in project-root/lib/attr/wrkgroup.h** origin ``` 26 | char F0, F1, F2; // formatting is deleted for better readability ``` in fix commit ``` 4 | #define ZERO = '\0' // Magic Number 0 Macro is added. . . . 26+1 (27) | char F0 = '\0', F1 = '\0', F2 = '\0'; ``` i don't know specific kinds of solution about this problem, then i initialize those variable '\0'
Author
Contributor
@seealso https://cwe.mitre.org/data/definitions/457.html
Owner

Adding an initialiser seems to be solid fix.
However two factors seems to be questionable:

  1. Unused macro which is named very general [ZERO]
  2. Fishy definition of ZERO (='\0') which seems to be having a statement out of its purpose

I have suggestion for you: Delete the macro ZERO which has very faulty behaviour.

Adding an initialiser seems to be solid fix. However two factors seems to be questionable: 1. Unused macro which is named very general [ZERO] 2. Fishy definition of ZERO (='\0') which seems to be having a statement out of its purpose I have suggestion for you: Delete the macro `ZERO` which has very faulty behaviour.
Author
Contributor

@dalmurii wrote in #3 (comment):

Adding an initialiser seems to be solid fix. However two factors seems to be questionable:

1. Unused macro which is named very general [ZERO]

2. Fishy definition of ZERO (='\0') which seems to be having a statement out of its purpose

I have suggestion for you to delete the macro ZERO which has very faulty behaviour.

FIX that questionable point. That macro is useless, i delete that

@dalmurii wrote in https://talkischeap.work.gd/ae3f/aclspv/pulls/3#issuecomment-57: > Adding an initialiser seems to be solid fix. However two factors seems to be questionable: > > 1. Unused macro which is named very general [ZERO] > > 2. Fishy definition of ZERO (='\0') which seems to be having a statement out of its purpose > > > I have suggestion for you to delete the macro `ZERO` which has very faulty behaviour. FIX that questionable point. That macro is useless, i delete that
Owner

Squishing commits would be required to keep diff simple

Squishing commits would be required to keep diff simple
dalmurii changed title from fix analyzer use of uninitialized char variable's value to WIP: fix analyzer use of uninitialized char variable's value 2026-05-08 13:36:23 +00:00
dalmurii changed title from WIP: fix analyzer use of uninitialized char variable's value to fix analyzer use of uninitialized char variable's value 2026-05-08 13:36:30 +00:00
Author
Contributor

@dalmurii wrote in #3 (comment):

Squishing commits would be required to keep diff simple

compeleted

@dalmurii wrote in https://talkischeap.work.gd/ae3f/aclspv/pulls/3#issuecomment-60: > Squishing commits would be required to keep diff simple compeleted
dalmurii merged commit ce1c0cc2d9 into master 2026-05-08 13:51:59 +00:00
Sign in to join this conversation.
No description provided.