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

Rebase branch from smbios-3.3.0 to master #46

Merged
merged 28 commits into from
Oct 26, 2022
Merged

Conversation

HuO50
Copy link
Collaborator

@HuO50 HuO50 commented Oct 26, 2022

Hello All:
After smbios-3.3.0 branch testing by @lian-bo & @lichliu , I request to rebase smbios-3.3.0 to master.

HuO50 and others added 28 commits September 4, 2022 20:36
Details:
    1. Change default /dev/mem to sysfs tables, if /dev/mem is unavailable, use sysfs tables instead.
    2. Modify init method from dmidecodemodule.
    3. Add read_file function instead memchunk.
    4. Add SM3 reading function and get version function.
    5. Test physical machine and KVM machine

Resolves: nima#39
Signed-off-by: Huzz <[email protected]>
…ix check smbios version error warning message.
The "/dev/mem" may be disabled(e.g kernel enables lockdown), which makes
python-dmidecode has no permission to access the "/dev/mem". As a
result, python-dmidecode will report an error as below:

  ** COLLECTED WARNINGS **
  Failed to open memory buffer (/dev/mem): Permission denied
  No SMBIOS nor DMI entry point found, sorry.
  ** END OF WARNINGS **

Let's try to read the sysfs tables if the "/dev/mem" is unavailable.

Resolves: nima#15
Signed-off-by: Zhongze Hu <[email protected]>
Currently, python-dmidecode will print an empty dictionary as below:

  # python3
  Python 3.9.13 (main, Jul 25 2022, 00:00:00)
  [GCC 11.3.1 20220421 (Red Hat 11.3.1-2)] on linux
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import dmidecode
  >>> dmidecode.bios()
  {}
  >>>

This patch will solve the above issue.

Signed-off-by: Zhongze Hu <[email protected]>
1. Update case 1 to case 42 to smbios 3.3.0;
2. Add case 43 for TPM device and Redfish;
3. Add case 43 in pymap file;
4. Using OUT_OF_SPEC Macro for outofspec string;
5. Modify smbios version to 0x030300
6. Test this commit by private/dumpfiles
Update python-dmidecode to smbios 3.3.0
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
fix gcc compiling warning info for Smbios 3.3.0
    Case 13(System Slot): function dmi_slot_segment_bus_func may cause
core dump error by null point sub_n.
fix function dmi_slot_segment_bus_func null point error in system slot
change LOG_WARNING level into LOG_DEBUG
Copy link
Collaborator

@lian-bo lian-bo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Thank you for the work, Zhongze.

@lian-bo lian-bo merged commit e6ab5bc into nima:master Oct 26, 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