Skip to content

Fix Compilation Warnings and Errors #1

@IanoNjuguna

Description

@IanoNjuguna

The get_cpu_type function produces compilation warnings related to a missing pre-processor directive declaration:

detect-cpu.c: In function ‘get_cpu_type’:
detect-cpu.c:26:13: warning: implicit declaration of function ‘strncmp’ [-Wimplicit-function-declaration]
   26 |         if (strncmp(line, "model name", 10) == 0)
      |             ^~~~~~~
detect-cpu.c:9:1: note: include ‘<string.h>’ or provide a declaration of ‘strncmp’
    8 | #include <sys/sysinfo.h>
  +++ |+#include <string.h>
    9 |
detect-cpu.c:26:41: warning: ‘strncmp’ argument 3 type is ‘int’ where ‘long unsigned int’ is expected in a call to built-in function declared without prototype [-Wbuiltin-declaration-mismatch]
   26 |         if (strncmp(line, "model name", 10) == 0)
      |                                         ^~
<built-in>: note: built-in ‘strncmp’ declared here
detect-cpu.c:28:23: warning: implicit declaration of function ‘strchr’ [-Wimplicit-function-declaration]
   28 |             cputype = strchr(line, ':') + 2;
      |                       ^~~~~~
detect-cpu.c:28:23: note: include ‘<string.h>’ or provide a declaration of ‘strchr’
detect-cpu.c:28:23: warning: incompatible implicit declaration of built-in function ‘strchr’ [-Wbuiltin-declaration-mismatch]
detect-cpu.c:28:23: note: include ‘<string.h>’ or provide a declaration of ‘strchr’

The compiler recommends we add #include <string.h> for strncmp and strchr declarations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions