fix compiler warnings

This commit is contained in:
Mickael B 2017-07-29 02:02:14 -04:00 committed by Eric Soroos
parent 1ba6ff8a33
commit c55b3aa402
2 changed files with 7 additions and 4 deletions

View File

@ -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():

View File

@ -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 */