Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

security: Add compiler static analysis support #64595

Merged
merged 1 commit into from
Jan 25, 2024

Commits on Jan 17, 2024

  1. security: Add compiler static analysis support

    Enable GCC builtin static analysis in Zephyr's static code analysis
    (SCA) infra.
    
    When this option is enabled GCC performs a static analysis and
    can point problems like:
    
    sample.c
    
    +	int *j;
    +
    +	if (j != NULL) {
    +		printf("j != NULL\n");
    
    output:
    
    ${ZEPHYR_BASE}/samples/userspace/hello_world_user/src/main.c:30:12:
    warning: use of uninitialized value 'j' [CWE-457]
    [-Wanalyzer-use-of-uninitialized-value]
    
       30 |         if (j != NULL) {
          |            ^
      'main': events 1-2
        |
        |   25 |         int *j;
        |      |              ^
        |      |              |
        |      |              (1) region created on stack here
        |......
        |   30 |         if (j != NULL) {
        |      |            ~
        |      |            |
        |      |            (2) use of uninitialized value 'j' here
    
    Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
    ceolin committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    a9c7507 View commit details
    Browse the repository at this point in the history