From c55b3aa402f5d130bd6d8cf7727502b969127e05 Mon Sep 17 00:00:00 2001 From: Mickael B Date: Sat, 29 Jul 2017 02:02:14 -0400 Subject: [PATCH] fix compiler warnings --- PIL/SgiImagePlugin.py | 7 +++++-- libImaging/SgiRleDecode.c | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/PIL/SgiImagePlugin.py b/PIL/SgiImagePlugin.py index 42372da75..a6bd1d93d 100644 --- a/PIL/SgiImagePlugin.py +++ b/PIL/SgiImagePlugin.py @@ -151,6 +151,11 @@ def _save(im, fp, filename): dim = 2 # Z Dimension: Number of channels z = len(im.mode) + + # assert we've got the right number of bands. + if len(im.getbands()) != z: + raise ValueError("incorrect number of bands in SGI write: %s vs %s" % + (z, len(im.getbands()))) if dim == 1 or dim == 2: z = 1 # assert we've got the right number of bands. @@ -177,12 +182,10 @@ def _save(im, fp, filename): fp.write(struct.pack('>H', z)) fp.write(struct.pack('>l', pinmin)) fp.write(struct.pack('>l', pinmax)) - fp.write(struct.pack('4s', b'')) # dummy fp.write(struct.pack('79s', imgName)) # truncates to 79 chars fp.write(struct.pack('s', b'')) # force null byte after imgname fp.write(struct.pack('>l', colormap)) - fp.write(struct.pack('404s', b'')) # dummy for channel in im.split(): diff --git a/libImaging/SgiRleDecode.c b/libImaging/SgiRleDecode.c index 133f30196..65dd7677a 100644 --- a/libImaging/SgiRleDecode.c +++ b/libImaging/SgiRleDecode.c @@ -93,7 +93,7 @@ ImagingSgiRleDecode(Imaging im, ImagingCodecState state, UINT8* buf, int bytes) { uint32_t *starttab, *lengthtab, rleoffset, rlelength; - int tablen, i, j, rowno, channo, bpc; + int tablen, i, j, rowno, channo; long bufsize; UINT8 *ptr; SGISTATE *context; @@ -104,7 +104,7 @@ ImagingSgiRleDecode(Imaging im, ImagingCodecState state, bufsize -= SGI_HEADER_SIZE; ptr = malloc(sizeof(UINT8) * bufsize); _imaging_seek_pyFd(state->fd, SGI_HEADER_SIZE, SEEK_SET); - _imaging_read_pyFd(state->fd, ptr, bufsize); + _imaging_read_pyFd(state->fd, (char*)ptr, bufsize); /* decoder initialization */