File imlib-codecleanup.diff of Package imlib
--- Imlib/load.c
+++ Imlib/load.c
@@ -1513,8 +1513,8 @@
if ((i > 1) && (isdigit(s[i - 2])))
{
ptr[a++] = ((atoi(s)) * 255) / scale;
- ptr[a++] = ptr[a - 1];
- ptr[a++] = ptr[a - 1];
+ ptr[a] = ptr[a - 1]; a++;
+ ptr[a] = ptr[a - 1]; a++;
}
i = 0;
}
@@ -1531,8 +1531,8 @@
if ((i > 1) && (isdigit(s[i - 2])))
{
ptr[a++] = atoi(s);
- ptr[a++] = ptr[a - 1];
- ptr[a++] = ptr[a - 1];
+ ptr[a] = ptr[a - 1]; a++;
+ ptr[a] = ptr[a - 1]; a++;
}
i = 0;
}
--- gdk_imlib/colors.c
+++ gdk_imlib/colors.c
@@ -21,7 +21,8 @@
&bytes_after, &retval);
if ((retval) && (num_ret > 0) && (format_ret > 0)) {
if (format_ret == 8) {
- int j, i, pnum;
+ int i, pnum;
+ unsigned j;
pnum = (int) (retval[0]);
j = 1;
--- gdk_imlib/io-png.c
+++ gdk_imlib/io-png.c
@@ -324,7 +324,7 @@
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
return NULL;
}
- for (i = 0; i < hh; i++)
+ for (i = 0; (unsigned)i < hh; i++)
{
if ((lines[i] = malloc(ww * (sizeof(unsigned char) * 4))) == NULL)
{
@@ -346,10 +346,10 @@
if ((color_type == PNG_COLOR_TYPE_GRAY) ||
(color_type == PNG_COLOR_TYPE_GRAY_ALPHA))
{
- for (y = 0; y < hh; y++)
+ for (y = 0; (unsigned)y < hh; y++)
{
ptr2 = lines[y];
- for (x = 0; x < ww; x++)
+ for (x = 0; (unsigned)x < ww; x++)
{
r = *ptr2++;
a = *ptr2++;
@@ -371,10 +371,10 @@
}
else
{
- for (y = 0; y < hh; y++)
+ for (y = 0; (unsigned)y < hh; y++)
{
ptr2 = lines[y];
- for (x = 0; x < ww; x++)
+ for (x = 0; (unsigned)x < ww; x++)
{
r = *ptr2++;
g = *ptr2++;
@@ -398,7 +398,7 @@
}
}
}
- for (i = 0; i < hh; i++)
+ for (i = 0; (unsigned)i < hh; i++)
free(lines[i]);
free(lines);
if (transp)
--- gdk_imlib/io-ppm.c
+++ gdk_imlib/io-ppm.c
@@ -176,8 +176,10 @@
if ((i > 1) && (isdigit(s[i - 2])))
{
ptr[a++] = ((atoi(s)) * 255) / scale;
- ptr[a++] = ptr[a - 1];
- ptr[a++] = ptr[a - 1];
+ ptr[a] = ptr[a - 1];
+ a++;
+ ptr[a] = ptr[a - 1];
+ a++;
}
i = 0;
}
@@ -194,8 +196,10 @@
if ((i > 1) && (isdigit(s[i - 2])))
{
ptr[a++] = atoi(s);
- ptr[a++] = ptr[a - 1];
- ptr[a++] = ptr[a - 1];
+ ptr[a] = ptr[a - 1];
+ a++;
+ ptr[a] = ptr[a - 1];
+ a++;
}
i = 0;
}
--- gdk_imlib/modules.c
+++ gdk_imlib/modules.c
@@ -75,13 +75,15 @@
static gboolean
get_module_loader_saver (char *mod,
- void **loader, void *def_loader,
- void **saver, void *def_saver)
+ void *ldr, void *def_loader,
+ void *svr, void *def_saver)
{
char *path, *modname;
GModule *m;
gboolean v;
void *ptr;
+ void **loader = (void **)ldr;
+ void **saver = (void **)svr;
modname = g_strconcat ("imlib-", mod, NULL);
path = g_module_build_path (IMLIB_LIB, modname);
@@ -149,8 +151,8 @@
load_module_relay (char *mod, gdk_imlib_loader_fn *lf, gdk_imlib_saver_fn *sf, FILE *f, int *w, int *h, int *t)
{
get_module_loader_saver (mod,
- (void **) lf, (void *) load_fail_fn,
- (void **) sf, (void *) save_fail_fn);
+ lf, load_fail_fn,
+ sf, save_fail_fn);
return (*lf)(f, w, h, t);
}
@@ -159,9 +161,9 @@
save_module_relay (char *mod, gdk_imlib_loader_fn *lf, gdk_imlib_saver_fn *sf,
GdkImlibImage *im, char *fname, GdkImlibSaveInfo *info)
{
- get_module_loader_saver (mod,
- (void **) lf, (void *) load_fail_fn,
- (void **) sf, (void *) save_fail_fn);
+ get_module_loader_saver (mod,
+ lf, load_fail_fn,
+ sf, save_fail_fn);
return (*sf)(im, fname, info);
}
@@ -169,9 +171,8 @@
static unsigned char *
loader_tiff (FILE *f, char *n, int *w, int *h, int *t)
{
- get_module_loader_saver ("tiff",
- (void **) &_gdk_imlib_LoadTIFF, (void *) load_fail_fn,
- (void **) &_gdk_imlib_SaveTIFF, (void *) save_fail_fn);
+ get_module_loader_saver ("tiff", &_gdk_imlib_LoadTIFF, load_fail_fn,
+ &_gdk_imlib_SaveTIFF, save_fail_fn);
return _gdk_imlib_LoadTIFF (f, n, w, h, t);
}
@@ -222,7 +223,7 @@
saver_tiff (GdkImlibImage *im, char *file, GdkImlibSaveInfo *info)
{
return save_module_relay ("tiff",
- (gdk_imlib_loader_fn *) &_gdk_imlib_LoadTIFF,
+ &_gdk_imlib_LoadTIFF,
&_gdk_imlib_SaveTIFF, im, file, info);
}
@@ -257,9 +258,8 @@
static GdkImlibImage *
inline_png (unsigned char *data, int data_size)
{
- get_module_loader_saver ("png",
- (void **) &_gdk_imlib_LoadPNG, load_fail_fn,
- (void **) &_gdk_imlib_SavePNG, save_fail_fn);
+ get_module_loader_saver ("png", &_gdk_imlib_LoadPNG, load_fail_fn,
+ &_gdk_imlib_SavePNG, save_fail_fn);
return _gdk_imlib_inlined_png_to_image (data, data_size);
}
@@ -267,8 +267,8 @@
loader_alpha_png (char *file)
{
get_module_loader_saver ("png",
- (void **) &_gdk_imlib_LoadPNG, load_fail_fn,
- (void **) &_gdk_imlib_SavePNG, save_fail_fn);
+ &_gdk_imlib_LoadPNG, load_fail_fn,
+ &_gdk_imlib_SavePNG, save_fail_fn);
return _gdk_imlib_load_alpha_png (file);
}
#endif
--- gdk_imlib/utils.c
+++ gdk_imlib/utils.c
@@ -1372,12 +1372,12 @@
ls = strlen(s);
- if (col[0] && colptr < sizeof(col))
+ if (col[0] && (size_t)colptr < sizeof(col))
{
strcpy(col + colptr, " ");
colptr++;
}
- if (colptr + ls < sizeof(col))
+ if ((size_t)(colptr + ls) < sizeof(col))
{
strcpy(col + colptr, s);
colptr += ls;
@@ -1422,12 +1422,12 @@
ls = strlen(s);
- if (col[0] && colptr < sizeof(col))
+ if (col[0] && (size_t)colptr < sizeof(col))
{
strcpy(col + colptr, " ");
colptr++;
}
- if (ls + colptr < sizeof(col))
+ if ((size_t)(ls + colptr) < sizeof(col))
{
strcpy(col + colptr, s);
colptr += ls;