summaryrefslogtreecommitdiff
path: root/camlibs/sierra
diff options
context:
space:
mode:
authorSiim Meerits <sh0@yutani.ee>2020-08-13 00:55:13 +0300
committerMarcus Meissner <marcus@jet.franken.de>2020-08-31 12:41:41 +0200
commit6b4c07408f848ba2ff2a6581b06f5e7a01903d9c (patch)
tree901740853e22f900796837cd3c4658451479412f /camlibs/sierra
parent950e39f9dc151bc601aa769e7705b937d2b10b4b (diff)
downloadlibgphoto2-6b4c07408f848ba2ff2a6581b06f5e7a01903d9c.tar.gz
Fix sierra camlib compilation warnings.
* library.c: * sierra_list_folders(...): Change 'i' type to signed for trivial 'for' loop where it is compared to signed integer. * sierra_read_packet(...): Unsigned 16-bit little-endian checksum is compiled from two 8-bit values, but the bytes are not cast to correct size. Fix the issue by casting bytes to larger unsigned values. * sierra_set_speed(...): Add cast to 'unsigned int' to 'settings.serial.speed' in signed-unsigned compare. This retains current code behavior. * olympus-desc.c: Comment out unused variables. * sierra-desc.c: * camera_cam_desc_get_widget(...): Change 'value' variable type to 'unsigned int'. Previously this variable pointer was already cast to unsigned for filling and used in signed-unsigned compare as unsigned. Hence it has no behavior changes. * All other changes are basically the same. Signed 'for' loop counters were changed to unsigned type as they were already used as unsigned integers in loop comparisons. * sierra-usbwrap.c: Cast signed integer to unsigned to quiet signed-unsigned comparison warning. No behavior change. * sierra.c: * Comment out unused static variables. * put_file_func(...): Ensure 'available_memory' is not negative and cast to unsigned int to quiet compiler warning. * camera_init(...): Cast 'i' to unsigned int to quiet signed-unsigned compare warning. No behavior change.
Diffstat (limited to 'camlibs/sierra')
-rw-r--r--camlibs/sierra/library.c8
-rw-r--r--camlibs/sierra/olympus-desc.c7
-rw-r--r--camlibs/sierra/sierra-desc.c13
-rw-r--r--camlibs/sierra/sierra-usbwrap.c2
-rw-r--r--camlibs/sierra/sierra.c8
5 files changed, 24 insertions, 14 deletions
diff --git a/camlibs/sierra/library.c b/camlibs/sierra/library.c
index 21f790266..8087322aa 100644
--- a/camlibs/sierra/library.c
+++ b/camlibs/sierra/library.c
@@ -200,8 +200,8 @@ int sierra_list_files (Camera *camera, const char *folder, CameraList *list, GPC
int sierra_list_folders (Camera *camera, const char *folder, CameraList *list,
GPContext *context)
{
- int j, count;
- unsigned int i, bsize;
+ int i, j, count;
+ unsigned int bsize;
char buf[1024];
/* List the folders only if the camera supports them */
@@ -680,7 +680,7 @@ sierra_read_packet (Camera *camera, unsigned char *packet, GPContext *context)
for (c = 0, i = 4; i < br - 2; i++)
c += packet[i];
c &= 0xffff;
- if (c == (packet[br - 2] + (packet[br - 1] * 256)))
+ if (c == ((unsigned int)packet[br - 2] + ((unsigned int)packet[br - 1] * 256)))
break;
/*
@@ -983,7 +983,7 @@ sierra_set_speed (Camera *camera, SierraSpeed speed, GPContext *context)
* they are currently operating at that speed.
*/
CHECK (gp_port_get_settings (camera->port, &settings));
- if (settings.serial.speed == bit_rate)
+ if ((unsigned int)settings.serial.speed == bit_rate)
return GP_OK;
/*
diff --git a/camlibs/sierra/olympus-desc.c b/camlibs/sierra/olympus-desc.c
index 3bd55ab9c..5a128fc42 100644
--- a/camlibs/sierra/olympus-desc.c
+++ b/camlibs/sierra/olympus-desc.c
@@ -350,6 +350,7 @@ static const RegisterDescriptorType olysp500uz_reg_03[] = {
* does not work well, since only about 30 of some 16 million values are
* valid.
*/
+#if 0
static const ValueNameType olyrange_reg_03_val_names[] = {
{
{ .range = { 0, 16000000, 100 } }, NULL
@@ -362,6 +363,7 @@ static const RegisterDescriptorType olyrange_reg_03[] = {
VAL_NAME_INIT (olyrange_reg_03_val_names)
}
};
+#endif
/*
* Olympus 3040 Register 5: aperture settings. Works only in A or M mode
@@ -453,6 +455,7 @@ static const RegisterDescriptorType oly750uz_reg_05[] = {
/*
* Olympus SP-500uz Register 5: aperture settings.
*/
+#if 0
static const ValueNameType olysp500uz_reg_05_val_names[] = {
{ { 0 }, N_("Auto") },
{ { 28 }, "F2.8" },
@@ -473,6 +476,8 @@ static const RegisterDescriptorType olysp500uz_reg_05[] = {
VAL_NAME_INIT (olysp500uz_reg_05_val_names)
}
};
+#endif
+
/*
* Register 6: color mode
*/
@@ -820,6 +825,7 @@ static const RegisterDescriptorType oly750uz_reg_71[] = {
/*
* Oly SP-500 uz Register 71: optical zoom value.
*/
+#if 0
static const ValueNameType olysp500uz_reg_71_val_names[] = {
{
{ .range = { 6.3, 63.0, .3 } }, NULL
@@ -832,6 +838,7 @@ static const RegisterDescriptorType olysp500uz_reg_71[] = {
VAL_NAME_INIT (olysp500uz_reg_71_val_names)
}
};
+#endif
/*
* Oly 3040 Register 71: optical zoom value.
diff --git a/camlibs/sierra/sierra-desc.c b/camlibs/sierra/sierra-desc.c
index d100b5c18..8918912d7 100644
--- a/camlibs/sierra/sierra-desc.c
+++ b/camlibs/sierra/sierra-desc.c
@@ -112,7 +112,9 @@ static int
camera_cam_desc_get_widget (Camera *camera, CameraRegisterType *reg_p,
CameraWidget *section, GPContext *context)
{
- int ind, vind, ret, value;
+ int ret;
+ unsigned int value;
+ unsigned int ind, vind;
int mask;
char buff[1024];
CameraWidget *child;
@@ -139,7 +141,7 @@ camera_cam_desc_get_widget (Camera *camera, CameraRegisterType *reg_p,
* the fly and make a union with reg_value and a void*.
*/
ret = sierra_get_string_register (camera, reg_p->reg_number,
- -1, NULL, (unsigned char *)buff, (unsigned int *)&value, context);
+ -1, NULL, (unsigned char *)buff, &value, context);
if ((ret == GP_OK) && value != reg_p->reg_len) {
GP_DEBUG ("Bad length result %d", value);
return (GP_ERROR);
@@ -198,7 +200,7 @@ camera_get_config_cam_desc (Camera *camera, CameraWidget **window,
GPContext *context)
{
CameraWidget *section;
- int indw, indr;
+ unsigned int indw, indr;
const CameraDescType *cam_desc = NULL;
GP_DEBUG ("*** camera_get_config_cam_desc");
@@ -360,7 +362,8 @@ static int
camera_cam_desc_set_widget (Camera *camera, CameraRegisterType *reg_p,
CameraWidget *window, GPContext *context)
{
- int ind, vind, ret;
+ int ret;
+ unsigned int ind, vind;
union value_in {
char *charp;
int val;
@@ -423,7 +426,7 @@ int
camera_set_config_cam_desc (Camera *camera, CameraWidget *window,
GPContext *context)
{
- int wind, rind;
+ unsigned int wind, rind;
const CameraDescType *cam_desc = NULL;
GP_DEBUG ("*** camera_set_config_cam_desc");
diff --git a/camlibs/sierra/sierra-usbwrap.c b/camlibs/sierra/sierra-usbwrap.c
index 449300fb6..cf8fbb595 100644
--- a/camlibs/sierra/sierra-usbwrap.c
+++ b/camlibs/sierra/sierra-usbwrap.c
@@ -459,7 +459,7 @@ usb_wrap_DATA (GPPort *dev, unsigned int type, char *sierra_response, int *sierr
msg_len = msg_len * 256 + (unsigned int)(size.c2);
msg_len = msg_len * 256 + (unsigned int)(size.c1);
- if (*sierra_len < msg_len - sizeof(*msg))
+ if ((unsigned int)*sierra_len < msg_len - sizeof(*msg))
{
GP_DEBUG( "usb_wrap_read_packet buffer too small! (%i < %i) *** FAILED", *sierra_len, msg_len);
return GP_ERROR;
diff --git a/camlibs/sierra/sierra.c b/camlibs/sierra/sierra.c
index 59fcc2389..71857d1f8 100644
--- a/camlibs/sierra/sierra.c
+++ b/camlibs/sierra/sierra.c
@@ -60,8 +60,8 @@ static int get_jpeg_data(const char *data, int data_size, char **jpeg_data, int
/* Useful markers */
static const char JPEG_SOI_MARKER[] = { (char)0xFF, (char)0xD8, '\0' };
static const char JPEG_SOF_MARKER[] = { (char)0xFF, (char)0xD9, '\0' };
-static const char JPEG_APP1_MARKER[] = { (char)0xFF, (char)0xE1, '\0' };
-static const char TIFF_SOI_MARKER[] = { (char)0x49, (char)0x49, (char)0x2A, (char)0x00, (char)0x08, '\0' };
+/*static const char JPEG_APP1_MARKER[] = { (char)0xFF, (char)0xE1, '\0' };*/
+/*static const char TIFF_SOI_MARKER[] = { (char)0x49, (char)0x49, (char)0x2A, (char)0x00, (char)0x08, '\0' };*/
static struct {
const char *manuf;
@@ -782,7 +782,7 @@ put_file_func (CameraFilesystem * fs, const char *folder, const char *filename,
/* Check the available memory */
CHECK (sierra_get_memory_left(camera, &available_memory, context));
- if (available_memory < data_size) {
+ if (available_memory < 0 || (unsigned int)available_memory < data_size) {
gp_context_error (context,
_("Not enough memory available on the memory card"));
return GP_ERROR_NO_MEMORY;
@@ -2259,7 +2259,7 @@ camera_init (Camera *camera, GPContext *context)
/* Find the speed into abilities.speeds array.
* Highest speeds are last ... so look backwards ...
*/
- for (i=0;i<sizeof(a.speed)/sizeof(a.speed[0]) && a.speed[i];i++)
+ for (i=0;(unsigned int)i<sizeof(a.speed)/sizeof(a.speed[0]) && a.speed[i];i++)
/*empty*/;
i--;
for (; i >= 0 ; i--) {