From 950e39f9dc151bc601aa769e7705b937d2b10b4b Mon Sep 17 00:00:00 2001 From: Siim Meerits Date: Thu, 13 Aug 2020 00:45:52 +0300 Subject: [PATCH] Fix ricoh camlib compilation warnings. * g3.c: * get_file_func(...): Change variable 'seek' type to 'int'. Currently 'sscanf' already reads a signed decimal into 'seek' and a following comparison uses negative constant (-2). This change should not change behavior in practice. * folder_list_func(...): Variable 'n' is used in trivial 'for' loop already as unsigned so change the the type accordingly. No behavior changes. * file_list_func(...): Same as above. * library.c: * camera_init(...): Add cast to 'unsigned int' to avoid signed-unsigned compare warning. This does not change code behavior. --- camlibs/ricoh/g3.c | 8 +++++--- camlibs/ricoh/library.c | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/camlibs/ricoh/g3.c b/camlibs/ricoh/g3.c index 2570df5c4..32c6495ac 100644 --- a/camlibs/ricoh/g3.c +++ b/camlibs/ricoh/g3.c @@ -358,7 +358,8 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename, { Camera *camera = data; char *buf = NULL, *reply = NULL, *cmd =NULL, *msg = NULL; - unsigned int len, bytes, seek; + unsigned int len, bytes; + int seek; int ret, channel; ret = g3_cwd_command (camera->port, folder); @@ -758,7 +759,7 @@ folder_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, free(cmd);cmd = NULL; if (ret < GP_OK) goto out; if (buf[0] == '1') { /* 1xx means another reply follows */ - int n = 0; + unsigned int n = 0; ret = g3_channel_read(camera->port, &channel, &buf, &len); /* data. */ if (ret < GP_OK) goto out; @@ -805,7 +806,8 @@ file_list_func (CameraFilesystem *fs, const char *folder, CameraList *list, free(cmd); cmd = NULL; if (ret < GP_OK) goto out; if (buf[0] == '1') { /* 1xx means another reply follows */ - int n = 0, channel; + unsigned int n = 0; + int channel; unsigned int len, rlen; ret = g3_channel_read(camera->port, &channel, &buf, &len); /* data. */ if (ret < GP_OK) goto out; diff --git a/camlibs/ricoh/library.c b/camlibs/ricoh/library.c index 7ee831c60..c40ab42c9 100644 --- a/camlibs/ricoh/library.c +++ b/camlibs/ricoh/library.c @@ -565,7 +565,7 @@ camera_init (Camera *camera, GPContext *context) } /* Contact made. Do we need to change the speed? */ - if (settings.serial.speed != speed) { + if ((unsigned int)settings.serial.speed != speed) { for (i = 0; speeds[i].speed; i++) if (speeds[i].speed == speed) break;