Skip to content

Commit 4cf33dd

Browse files
authored
Merge pull request #1715 from dbwiddis/fix-name-path
Fix UdevDevice.getSysname() calling udev_device_get_syspath
2 parents 8bfebbe + 3156f4a commit 4cf33dd

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Features
1313
Bug Fixes
1414
---------
1515
* [#1644](https://github.com/java-native-access/jna/issues/1644): Fix bug in VARDESC and TYPEDESC causing an illegal memory access - [@lwahonen](https://github.com/lwahonen)
16+
* [#1715](https://github.com/java-native-access/jna/pull/1715): Fix `UdevDevice.getSysname()` calling `udev_device_get_syspath` instead of `udev_device_get_sysname` - [@dbwiddis](https://github.com/dbwiddis).
1617

1718
Release 5.18.1
1819
==============

contrib/platform/src/com/sun/jna/platform/linux/Udev.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public String getSyspath() {
233233
* @return a string that describes the sysname. On failure, may return NULL.
234234
*/
235235
public String getSysname() {
236-
return INSTANCE.udev_device_get_syspath(this);
236+
return INSTANCE.udev_device_get_sysname(this);
237237
}
238238

239239
/**

contrib/platform/test/com/sun/jna/platform/linux/UdevTest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ public void testEnumerateDevices() {
111111
assertEquals(String.format("DevType mismatch (%s)", devnode), devType, device.getDevtype());
112112
assertEquals(String.format("Subsystem mismatch (%s)", devnode), "block", device.getSubsystem());
113113
assertEquals(String.format("Syspath mismatch (%s)", devnode), syspath, device.getSyspath());
114-
assertTrue(String.format("Syspath should end with name (%s)", devnode), syspath.endsWith(device.getSysname()));
114+
String sysname = device.getSysname();
115+
assertTrue(String.format("Syspath should end with name (%s)", devnode), syspath.endsWith(sysname));
116+
assertTrue(String.format("Sysname should be shorter than syspath (%s)", devnode), sysname.length() < syspath.length());
115117
}
116118
} finally {
117119
// Release the reference and iterate to the next device

0 commit comments

Comments
 (0)