Skip to content

Commit 4989a4b

Browse files
committed
Fix CICD feedback.
1 parent 547e275 commit 4989a4b

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/main/cpp/windows/jssc.cpp

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,16 @@
2929
#include <jssc_SerialNativeInterface.h>
3030
#include "version.h"
3131

32-
//#include <iostream>
32+
#if defined(_MSC_VER) && _MSC_VER < 1800
33+
# define PRIsz "Iu"
34+
# define PRIssz "Id"
35+
#elif defined(__MINGW32__) && !defined(__MINGW64__)
36+
# define PRIsz "lu"
37+
# define PRIssz "ld"
38+
#else
39+
# define PRIsz "zu"
40+
# define PRIssz "zd"
41+
#endif
3342

3443
#define MAX_PORT_NAME_STR_LEN 32
3544

@@ -283,8 +292,8 @@ JNIEXPORT jint JNICALL Java_jssc_SerialNativeInterface_writeBytes
283292
delete overlapped;
284293
if( err ){
285294
char emsg[128];
286-
snprintf(emsg, sizeof emsg, "Error %d: https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes#system-error-codes", err);
287-
jobject *exClz = env->FindClass("jssc/SerialPortException");
295+
snprintf(emsg, sizeof emsg, "Error %lu: https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes#system-error-codes", err);
296+
jclass exClz = env->FindClass("jssc/SerialPortException");
288297
if( exClz ) env->ThrowNew(exClz, emsg);
289298
}
290299
return returnValue;
@@ -321,7 +330,7 @@ JNIEXPORT jbyteArray JNICALL Java_jssc_SerialNativeInterface_readBytes
321330
lpBuffer = (jbyte*)malloc(byteCount*sizeof*lpBuffer);
322331
if( !lpBuffer ){
323332
char emsg[32]; emsg[0] = '\0';
324-
snprintf(emsg, sizeof emsg, "malloc(%d) failed", byteCount*sizeof*lpBuffer);
333+
snprintf(emsg, sizeof emsg, "malloc(%"PRIsz") failed", byteCount*sizeof*lpBuffer);
325334
jclass exClz = env->FindClass("java/lang/RuntimeException");
326335
if( exClz ) env->ThrowNew(exClz, emsg);
327336
returnArray = NULL; goto Finally;

0 commit comments

Comments
 (0)