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 bogus invocation of _pyReturnError() in __dmidecode_xml_getsection() #57

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

glaubitz
Copy link

@glaubitz glaubitz commented Jun 6, 2024

Fixes the following error:

src/dmidecodemodule.c: In function ‘__dmidecode_xml_getsection’: src/dmidecodemodule.c:482:90: error: passing argument 3 of ‘_pyReturnError’ makes integer from pointer without a cast [-Wint-conversion]
482 | _pyReturnError(PyExc_RuntimeError, "Invalid type id '%s' -- %s", typeid, err);
| ^~~~~~
| |
|

Fixes the following error:

src/dmidecodemodule.c: In function ‘__dmidecode_xml_getsection’:
src/dmidecodemodule.c:482:90: error: passing argument 3 of ‘_pyReturnError’ makes integer from pointer without a cast [-Wint-conversion]
  482 |                         _pyReturnError(PyExc_RuntimeError, "Invalid type id '%s' -- %s", typeid, err);
      |                                                                                          ^~~~~~
      |                                                                                          |
      |
@DuratarskeyK
Copy link

DuratarskeyK commented Jul 14, 2024

I think they meant to call PyReturnError here.
https://github.com/nima/python-dmidecode/blob/master/src/dmierror.h#L48
The signature matches with what's being passed as arguments.

@glaubitz
Copy link
Author

glaubitz commented Jul 14, 2024

I think they meant to call PyReturnError here. https://github.com/nima/python-dmidecode/blob/master/src/dmierror.h#L48 The signature matches with what's being passed as arguments.

Nope, PyReturnError() is a macro that contains a return instruction and would end the execution __dmidecode_xml_getsection() prematurely so that the following call to free() would be missed.

@DuratarskeyK
Copy link

DuratarskeyK commented Jul 14, 2024

Right. Well, at least I guess
NULL, 0 should become __FILE__, __LINE__

@glaubitz
Copy link
Author

glaubitz commented Jul 14, 2024 via email

@DuratarskeyK
Copy link

Those are standard macros that evaluate to file name and line.

hisshadow@uberlaptop ~ $ cat  2.c
__FILE__
__LINE__
hisshadow@uberlaptop ~ $ gcc -E 2.c
# 0 "2.c"
# 0 "<built-in>"
# 0 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 0 "<command-line>" 2
# 1 "2.c"
"2.c"
2

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