Skip to content

Fix UdevDevice.getSysname() calling udev_device_get_syspath#1715

Merged
dbwiddis merged 1 commit intojava-native-access:masterfrom
dbwiddis:fix-name-path
Apr 13, 2026
Merged

Fix UdevDevice.getSysname() calling udev_device_get_syspath#1715
dbwiddis merged 1 commit intojava-native-access:masterfrom
dbwiddis:fix-name-path

Conversation

@dbwiddis
Copy link
Copy Markdown
Contributor

UdevDevice.getSysname() has been calling udev_device_get_syspath since it was introduced in 2020 -- a sloppy copy-paste bug by whoever wrote it. At least he caught the bug six years later.

The existing test technically covered this with:

  assertTrue(syspath.endsWith(device.getSysname()));

But since getSysname() returned the syspath itself, syspath.endsWith(syspath) is always true, so the bug sailed right through.

Added test assertion that sysname is strictly shorter than syspath, which would have caught this originally.

udev_device_get_sysname

UdevDevice.getSysname() was calling udev_device_get_syspath instead of
udev_device_get_sysname due to a copy-paste error.

Fix: getSysname() now calls udev_device_get_sysname.

Test: added assertion that sysname is strictly shorter than syspath,
which
would have caught this originally.
Copy link
Copy Markdown
Member

@matthiasblaesing matthiasblaesing left a comment

Choose a reason for hiding this comment

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

Makes sense to me. I bet some poor soul did not read the docs, but it is the right thing to do.

@dbwiddis
Copy link
Copy Markdown
Contributor Author

I bet some poor soul did not read the docs

I've heard this type of copy-paste bug is one of the most common bug types, particularly at the start or end of a list. Easily flagged by today's automated AI code reviewers.

Speaking of which, you might consider installing CodeRabbit on this repo. It's immensely helped me on other repos I maintain in getting through that initial back-and-forth with the contributor to handle obvious things before a human spends time reviewing it. It's free for open source.... and 80% of its findings are useful (and it learns from you if you comment on the non useful ones.)

@dbwiddis dbwiddis merged commit 4cf33dd into java-native-access:master Apr 13, 2026
17 of 24 checks passed
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