Skip to content

Commit

Permalink
fix a few random compiler warnings
Browse files Browse the repository at this point in the history
 * unused variables
 * implicit enum conversion
 * sigend <-> unsigned comparison
 * left shift negative number

The only warnings left on my setup right now are `-Wstringop-truncation`
from strncpy calls. Those are not trivial to fix. Turns out the code does
regularly not take into account that strncpy may not result in a null
terminated string. Details, see `man string_copying`.
  • Loading branch information
axxel authored and msmeissn committed Sep 16, 2024
1 parent aa4197e commit 2e17f8e
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion camlibs/ax203/ax203_decode_yuv_delta.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

#define CLAMP_U8(x) (((x) > 255) ? 255 : (((x) < 0) ? 0 : (x)))

#ifdef HAVE_LIBGD
static const int corr_tables[4][8] = {
/* Table 0 depends on wrap around to get negative
corrections!! */
Expand All @@ -52,7 +53,6 @@ static const int corr_tables[4][8] = {
{ 0, 4, 8, 12, -16, -12, -8, -4 },
};

#ifdef HAVE_LIBGD
/* With in a compressed 4x4 block, the data is stored 4 component values at a
time, compressed into 2 bytes, the first 5 bits are a starting value,
then 2 bits encoding which correction/delta table to use and
Expand Down
2 changes: 1 addition & 1 deletion camlibs/pentax/pslr.c
Original file line number Diff line number Diff line change
Expand Up @@ -982,7 +982,7 @@ int pslr_set_exposure_mode(pslr_handle_t h, pslr_exposure_mode_t mode) {
}

if ( p->model->need_exposure_mode_conversion ) {
mode = exposure_mode_conversion( mode );
mode = (pslr_exposure_mode_t)exposure_mode_conversion( mode );
}

return ipslr_handle_command_x18( p, true, X18_EXPOSURE_MODE, 2, 1, mode, 0);
Expand Down
2 changes: 1 addition & 1 deletion camlibs/ptp2/ptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ fd_putfunc(PTPParams* params, void* private,
PTPFDHandlerPrivate* priv = (PTPFDHandlerPrivate*)private;

written = write (priv->fd, data, sendlen);
if (written != sendlen)
if ((unsigned long)written != sendlen)
return PTP_ERROR_IO;
return PTP_RC_OK;
}
Expand Down
2 changes: 1 addition & 1 deletion camlibs/quicktake1x0/qtkn-decoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ int qtkn_decode(unsigned char *raw, int width, int height, unsigned char **out)
for (c=0; c < 3; c++) {
val = ((0x1000000/last[c] + 0x7ff) >> 12) * mul[c];
s = val > 65564 ? 10:12;
x = ~(-1 << (s-1));
x = ~((unsigned int)-1 << (s-1));
val <<= 12-s;
for (i=0; i < (int)(sizeof(buf[0])/sizeof(short)); i++) {
((short *)buf[c])[i] = (((short *)buf[c])[i] * val + x) >> s;
Expand Down
4 changes: 2 additions & 2 deletions camlibs/tp6801/library.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ get_file_func (CameraFilesystem *fs, const char *folder, const char *filename,
GPContext *context)
{
Camera *camera = data;
int idx, size;
int idx;
#ifdef HAVE_LIBGD
int ret;
int ret, size;
gdImagePtr im;
void *gdpng;
#endif
Expand Down

0 comments on commit 2e17f8e

Please sign in to comment.