Skip to content

Commit cf0fc71

Browse files
committed
Drop redundant OpenSlideFFM null checks
These were carried over from the JNI implementation, where they were needed to prevent segfaults. With FFM, each of the affected variables is passed to arena.allocateFrom(), which properly throws a NullPointerException on null. That seems more correct than returning a method-specific sentinel value, since none of these methods should ever receive null in normal operation. Signed-off-by: Benjamin Gilbert <[email protected]>
1 parent 39c3814 commit cf0fc71

File tree

1 file changed

+0
-21
lines changed

1 file changed

+0
-21
lines changed

org/openslide/OpenSlideFFM.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,6 @@ private static RuntimeException wrapException(Throwable ex) {
234234
C_POINTER, "openslide_detect_vendor", C_POINTER);
235235

236236
static String openslide_detect_vendor(String filename) {
237-
if (filename == null) {
238-
return null;
239-
}
240237
MemorySegment ret;
241238
try (Arena arena = Arena.ofConfined()) {
242239
ret = (MemorySegment) detect_vendor.invokeExact(
@@ -254,9 +251,6 @@ static String openslide_detect_vendor(String filename) {
254251
C_POINTER, "openslide_open", C_POINTER);
255252

256253
static OpenSlideRef openslide_open(String filename) {
257-
if (filename == null) {
258-
return null;
259-
}
260254
MemorySegment ret;
261255
try (Arena arena = Arena.ofConfined()) {
262256
ret = (MemorySegment) open.invokeExact(
@@ -390,9 +384,6 @@ static String[] openslide_get_property_names(OpenSlideRef osr) {
390384
C_POINTER, "openslide_get_property_value", C_POINTER, C_POINTER);
391385

392386
static String openslide_get_property_value(OpenSlideRef osr, String name) {
393-
if (name == null) {
394-
return null;
395-
}
396387
MemorySegment ret;
397388
try (Arena arena = Arena.ofConfined(); Ref.ScopedLock l = osr.lock()) {
398389
ret = (MemorySegment) get_property_value.invokeExact(
@@ -426,9 +417,6 @@ static String[] openslide_get_associated_image_names(OpenSlideRef osr) {
426417

427418
static void openslide_get_associated_image_dimensions(OpenSlideRef osr,
428419
String name, long dim[]) {
429-
if (name == null) {
430-
return;
431-
}
432420
try (Arena arena = Arena.ofConfined()) {
433421
MemorySegment w = arena.allocateFrom(JAVA_LONG, 0);
434422
MemorySegment h = arena.allocateFrom(JAVA_LONG, 0);
@@ -449,9 +437,6 @@ static void openslide_get_associated_image_dimensions(OpenSlideRef osr,
449437

450438
static void openslide_read_associated_image(OpenSlideRef osr, String name,
451439
int dest[]) {
452-
if (name == null) {
453-
return;
454-
}
455440
try (Arena arena = Arena.ofConfined()) {
456441
MemorySegment buf = arena.allocate(JAVA_INT, dest.length);
457442
try (Ref.ScopedLock l = osr.lock()) {
@@ -470,9 +455,6 @@ static void openslide_read_associated_image(OpenSlideRef osr, String name,
470455

471456
static long openslide_get_associated_image_icc_profile_size(
472457
OpenSlideRef osr, String name) {
473-
if (name == null) {
474-
return -1;
475-
}
476458
try (Arena arena = Arena.ofConfined(); Ref.ScopedLock l = osr.lock()) {
477459
return (long) get_associated_image_icc_profile_size.invokeExact(
478460
osr.getSegment(), arena.allocateFrom(name));
@@ -487,9 +469,6 @@ static long openslide_get_associated_image_icc_profile_size(
487469

488470
static void openslide_read_associated_image_icc_profile(OpenSlideRef osr,
489471
String name, byte dest[]) {
490-
if (name == null) {
491-
return;
492-
}
493472
try (Arena arena = Arena.ofConfined()) {
494473
MemorySegment buf = arena.allocate(JAVA_BYTE, dest.length);
495474
try (Ref.ScopedLock l = osr.lock()) {

0 commit comments

Comments
 (0)