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

Do not free a static string #238

Merged
merged 3 commits into from
Oct 3, 2022

Conversation

bbonev
Copy link
Member

@bbonev bbonev commented Sep 21, 2022

In file included from udevadm-hwdb.c:26:
In function ‘freep’,
inlined from ‘adm_hwdb’ at udevadm-hwdb.c:624:38:
../../src/shared/util.h:289:9: warning: ‘free’ called on a pointer to an unallocated object ‘"/usr/etc/udev/hwdb.bin"’ [-Wfree-nonheap-object]
289 | free(*(void**) p);
| ^~~~~~~~~~~~~~~~~
../../src/shared/util.h:289:9: warning: ‘free’ called on a pointer to an unallocated object ‘"/usr/etc/udev/hwdb.bin"’ [-Wfree-nonheap-object]

In file included from udevadm-hwdb.c:26:
In function ‘freep’,
    inlined from ‘adm_hwdb’ at udevadm-hwdb.c:624:38:
../../src/shared/util.h:289:9: warning: ‘free’ called on a pointer to an unallocated object ‘"/usr/etc/udev/hwdb.bin"’ [-Wfree-nonheap-object]
  289 |         free(*(void**) p);
      |         ^~~~~~~~~~~~~~~~~
../../src/shared/util.h:289:9: warning: ‘free’ called on a pointer to an unallocated object ‘"/usr/etc/udev/hwdb.bin"’ [-Wfree-nonheap-object]
@ArsenArsen
Copy link
Member

There's a bit more work to consider, the string is reassigned later down the function.

@bbonev
Copy link
Member Author

bbonev commented Sep 21, 2022

Thanks! Looks like I missed that...

- the value is unused anyways
- thanks to Arsen for spotting this

In file included from udevadm-hwdb.c:26:
In function ‘freep’,
    inlined from ‘adm_hwdb’ at udevadm-hwdb.c:624:38:
../../src/shared/util.h:289:9: warning: ‘free’ called on a pointer to an unallocated object ‘"/usr/etc/udev/hwdb.bin"’ [-Wfree-nonheap-object]
  289 |         free(*(void**) p);
      |         ^~~~~~~~~~~~~~~~~
../../src/shared/util.h:289:9: warning: ‘free’ called on a pointer to an unallocated object ‘"/usr/etc/udev/hwdb.bin"’ [-Wfree-nonheap-object]
@bbonev
Copy link
Member Author

bbonev commented Oct 3, 2022

Please check it again with the last commits...

Copy link
Member

@ArsenArsen ArsenArsen left a comment

Choose a reason for hiding this comment

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

ah, sorry, I saw the email but forgot; this should be fine (_cleanup_free_ calls freep calls free, which is defined to be no-op on NULL)

@bbonev bbonev merged commit 99b0381 into eudev-project:master Oct 3, 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