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

fix gcc compiling warning info for Smbios 3.3.0 #43

Merged
merged 16 commits into from
Oct 24, 2022

Conversation

HuO50
Copy link
Collaborator

@HuO50 HuO50 commented Oct 22, 2022

Hi , Everyone,
I have fixed the gcc warning problems in my code, and trying to solve warnings old code has. These fix warning patch also adjust some codes. Most warning caused by variables in dmidecode not used in python-dmidecode may cause warning. I have fixed them after testing to make sure them will not cause bad influence.
@lian-bo @lichliu , please test these patches if nesscery.

HuO50 and others added 16 commits October 22, 2022 19:16
src/dmidecodemodule.c:154:27: Warning argument 1 null where non-null expected [-Wnonnull]
  154 |                 } else if(memcmp(buf, "_SM_", 4) == 0) {
      |                           ^~~~~~~~~~~~~~~~~~~~~~
src/dmidecodemodule.c:158:27: Warning argument 1 null where non-null expected [-Wnonnull]
  158 |                 } else if(memcmp(buf, "_DMI_", 5) == 0) {
      |                           ^~~~~~~~~~~~~~~~~~~~~~~
src/dmidump.c:157:1:warning: ignoring return value of 'legacy_decode' [-Wreturn-type]
  157 | }
      | ^
src/util.c:225:76: warning: comparison of integer expressions of different signedness: 'long unsigned int' and '__off_t' {aka 'long int'} [-Wsign-compare]
  225 |         if (sigill_error ||  S_ISREG(statbuf.st_mode) && base + (off_t)len > statbuf.st_size )
      |                                                                            ^
src/util.c:225:55: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
  225 |         if (sigill_error ||  S_ISREG(statbuf.st_mode) && base + (off_t)len > statbuf.st_size )
      |
src/util.c:225:55: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
  225 |         if (sigill_error ||  S_ISREG(statbuf.st_mode) && (__off_t)(base + (off_t)len) > statbuf.st_size )
      |
src/efi.c:52:21: warning: variable 'eptype' set but not used [-Wunused-but-set-variable]
   52 |         const char *eptype;
      |
src/dmidecode.c:6274:21: warning: unused variable 'ver' [-Wunused-variable]
 6274 |                 u32 ver = (buf[0x07] << 16) + (buf[0x08] << 8) + buf[0x09];
      |                     ^~~
… pointer type

src/dmidecode.c:5248:60: warning: passing argument 3 of 'dmi_slot_peers' from incompatible pointer type [-Wincompatible-pointer-types]
 5248 |                         dmi_slot_peers(sect_n, data[0x12], h, data+0x13);
      |                                                            ^
      |                                                            |
      |                                                            struct dmi_header *
src/dmidecode.c:2471:52: note: expected 'const u8 *' {aka 'const unsigned char *'} but argument is of type 'struct dmi_header *'
 2471 | void dmi_slot_peers(xmlNode *node, u8 n, const u8 *data, struct dmi_header *h)
      |                                          ~~~~~~~~~~^~~~
src/dmidecode.c:5248:67: warning: passing argument 4 of 'dmi_slot_peers' from incompatible pointer type [-Wincompatible-pointer-types]
 5248 |                         dmi_slot_peers(sect_n, data[0x12], h, data+0x13);
      |                                                               ~~~~^~~~~
      |                                                                   |
      |                                                                   const u8 * {aka const unsigned char *}
src/dmidecode.c:2471:77: note: expected 'struct dmi_header *' but argument is of type 'const u8 *' {aka 'const unsigned char *'}
 2471 | void dmi_slot_peers(xmlNode *node, u8 n, const u8 *data, struct dmi_header *h)
….c:4788:24: warning: 'return' with a value, in function returning void [-Wreturn-type] 4788 | return data_n; | ^~~~~~
src/dmidecodemodule.c:350:12: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  350 |         if(buf = mem_chunk(opt->logdata, fp, 0x20, opt->devmem) == NULL ){
      |            ^~~
src/dmidecodemodule.c:206:12: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
  206 |         if(buf = mem_chunk(opt->logdata, fp, 0x20, opt->devmem) == NULL){
      |            ^~~
src/dmidecode.c:4446:21: warning: unused variable 'addrstr' [-Wunused-variable]
 4446 |         const char *addrstr;
      |                     ^~~~~~~
src/dmidecode.c: In function 'dmi_parse_protocol_record':
src/dmidecode.c:4448:14: warning: unused variable 'attr' [-Wunused-variable]
 4448 |         char attr[38];
      |              ^~~~
…from integer without a cast

src/dmidecode.c: In function 'dmi_decode':
src/dmidecode.c:6032:47: warning: passing argument 2 of 'dmi_tpm_vendor_id' makes pointer from integer without a cast [-Wint-conversion]
 6032 |                 dmi_tpm_vendor_id(sect_n, data[0x04]);
      |                                           ~~~~^~~~~~
      |                                               |
      |                                               u8 {aka unsigned char}
src/dmidecode.c: In function 'dmi_additional_info':
src/dmidecode.c:4262:42: warning: variable 'str_n' set but not used [-Wunused-but-set-variable]
 4262 |                 xmlNode *data_n = NULL, *str_n = NULL, *val_n = NULL;
      |                                          ^~~~~
src/dmidecodemodule.c: In function 'dmidecode_get_xml':
src/dmidecodemodule.c:394:25: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  394 |                         if(legacy_decode(opt->logdata, opt->type,
      |                         ^~
src/dmidecodemodule.c:397:33: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
  397 |                                 goto done;
      |                                 ^~~~
Merge pull request nima#42 from HuO50/smbios-3.3.0
@lian-bo lian-bo merged commit 1221d49 into nima:smbios-3.3.0 Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants