From 5d5dc61d1b6db02a72e54fcbd0b2a2cb8ff40900 Mon Sep 17 00:00:00 2001 From: Alison Watson Date: Mon, 25 Nov 2019 17:27:06 -0500 Subject: [PATCH] signed char -> int8_t (ISO/IEC 2382-1:1993) --- source/common.c | 2 +- source/gl_model.h | 2 +- source/gl_texmgr.h | 4 ++-- source/image.c | 26 +++++++++++++------------- source/lodepng.c | 2 +- source/snd_dma.c | 8 ++++---- source/snd_mem.c | 4 ++-- source/snd_mix.c | 6 +++--- source/snd_umx.c | 2 +- source/wad.h | 6 +++--- 10 files changed, 31 insertions(+), 31 deletions(-) diff --git a/source/common.c b/source/common.c index 44337ef..b04c0b0 100644 --- a/source/common.c +++ b/source/common.c @@ -775,7 +775,7 @@ int MSG_ReadChar (void) return -1; } - c = (signed char)net_message.data[msg_readcount]; + c = (int8_t)net_message.data[msg_readcount]; msg_readcount++; return c; diff --git a/source/gl_model.h b/source/gl_model.h index b956e9d..5b3c295 100644 --- a/source/gl_model.h +++ b/source/gl_model.h @@ -297,7 +297,7 @@ typedef struct aliasmesh_s typedef struct meshxyz_s { byte xyz[4]; - signed char normal[4]; + int8_t normal[4]; } meshxyz_t; typedef struct meshst_s diff --git a/source/gl_texmgr.h b/source/gl_texmgr.h index f915e47..25ec163 100644 --- a/source/gl_texmgr.h +++ b/source/gl_texmgr.h @@ -59,8 +59,8 @@ typedef struct gltexture_s { uint32_t source_width; //size of image in source data uint32_t source_height; //size of image in source data uint16_t source_crc; //generated by source data before modifications - char shirt; //0-13 shirt color, or -1 if never colormapped - char pants; //0-13 pants color, or -1 if never colormapped + int8_t shirt; //0-13 shirt color, or -1 if never colormapped + int8_t pants; //0-13 pants color, or -1 if never colormapped //used for rendering int visframe; //matches r_framecount if texture was bound this frame } gltexture_t; diff --git a/source/image.c b/source/image.c index b9ab96b..45dda11 100644 --- a/source/image.c +++ b/source/image.c @@ -61,7 +61,7 @@ static inline int Buf_GetC(stdio_buffer_t *buf) { buf->size = fread(buf->buffer, 1, sizeof(buf->buffer), buf->f); buf->pos = 0; - + if (buf->size == 0) return EOF; } @@ -384,18 +384,18 @@ byte *Image_LoadTGA (FILE *fin, int *width, int *height) typedef struct { - char signature; - char version; - char encoding; - char bits_per_pixel; - uint16_t xmin,ymin,xmax,ymax; - uint16_t hdpi,vdpi; - byte colortable[48]; - char reserved; - char color_planes; - uint16_t bytes_per_line; - uint16_t palette_type; - char filler[58]; + int8_t signature; + int8_t version; + int8_t encoding; + int8_t bits_per_pixel; + uint16_t xmin,ymin,xmax,ymax; + uint16_t hdpi,vdpi; + uint8_t colortable[48]; + int8_t reserved; + int8_t color_planes; + uint16_t bytes_per_line; + uint16_t palette_type; + uint8_t filler[58]; } pcxheader_t; /* diff --git a/source/lodepng.c b/source/lodepng.c index 6bf1af4..02462de 100644 --- a/source/lodepng.c +++ b/source/lodepng.c @@ -5292,7 +5292,7 @@ static unsigned filter(uint8_t* out, const uint8_t* in, unsigned w, unsigned h, for(x = 0; x != linebytes; ++x) { /*For differences, each byte should be treated as signed, values above 127 are negative - (converted to signed char). Filtertype 0 isn't a difference though, so use unsigned there. + (converted to int8_t). Filtertype 0 isn't a difference though, so use unsigned there. This means filtertype 0 is almost never chosen, but that is justified.*/ uint8_t s = attempt[type][x]; sum[type] += s < 128 ? s : (255U - s); diff --git a/source/snd_dma.c b/source/snd_dma.c index 15e461e..7ca475f 100644 --- a/source/snd_dma.c +++ b/source/snd_dma.c @@ -740,8 +740,8 @@ void S_RawSamples (int samples, int rate, int width, int channels, byte *data, f break; dst = s_rawend & (MAX_RAW_SAMPLES - 1); s_rawend++; - // s_rawsamples [dst].left = ((signed char *) data)[src * 2] * intVolume; - // s_rawsamples [dst].right = ((signed char *) data)[src * 2 + 1] * intVolume; + // s_rawsamples [dst].left = ((int8_t *) data)[src * 2] * intVolume; + // s_rawsamples [dst].right = ((int8_t *) data)[src * 2 + 1] * intVolume; s_rawsamples [dst].left = (((byte *) data)[src * 2] - 128) * intVolume; s_rawsamples [dst].right = (((byte *) data)[src * 2 + 1] - 128) * intVolume; } @@ -757,8 +757,8 @@ void S_RawSamples (int samples, int rate, int width, int channels, byte *data, f break; dst = s_rawend & (MAX_RAW_SAMPLES - 1); s_rawend++; - // s_rawsamples [dst].left = ((signed char *) data)[src] * intVolume; - // s_rawsamples [dst].right = ((signed char *) data)[src] * intVolume; + // s_rawsamples [dst].left = ((int8_t *) data)[src] * intVolume; + // s_rawsamples [dst].right = ((int8_t *) data)[src] * intVolume; s_rawsamples [dst].left = (((byte *) data)[src] - 128) * intVolume; s_rawsamples [dst].right = (((byte *) data)[src] - 128) * intVolume; } diff --git a/source/snd_mem.c b/source/snd_mem.c index 7af850e..306ec5b 100644 --- a/source/snd_mem.c +++ b/source/snd_mem.c @@ -60,7 +60,7 @@ static void ResampleSfx (sfx_t *sfx, int inrate, int inwidth, byte *data) { // fast special case for (i = 0; i < outcount; i++) - ((signed char *)sc->data)[i] = (int)( (uint8_t)(data[i]) - 128); + ((int8_t *)sc->data)[i] = (int)( (uint8_t)(data[i]) - 128); } else { @@ -78,7 +78,7 @@ static void ResampleSfx (sfx_t *sfx, int inrate, int inwidth, byte *data) if (sc->width == 2) ((int16_t *)sc->data)[i] = sample; else - ((signed char *)sc->data)[i] = sample >> 8; + ((int8_t *)sc->data)[i] = sample >> 8; } } } diff --git a/source/snd_mix.c b/source/snd_mix.c index ec5e496..7f7a741 100644 --- a/source/snd_mix.c +++ b/source/snd_mix.c @@ -135,7 +135,7 @@ static void S_TransferPaintBuffer (int endtime) } else if (shm->samplebits == 8) /* S8 format, e.g. with Amiga AHI */ { - signed char *out = (signed char *) shm->buffer; + int8_t *out = (int8_t *) shm->buffer; while (count--) { val = *p / 256; @@ -457,12 +457,12 @@ void SND_InitScaletable (void) for (j = 0; j < 256; j++) { /* When compiling with gcc-4.1.0 at optimisations O1 and - higher, the tricky signed char type conversion is not + higher, the tricky int8_t type conversion is not guaranteed. Therefore we explicity calculate the signed value from the index as required. From Kevin Shanahan. See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26719 */ - // snd_scaletable[i][j] = ((signed char)j) * scale; + // snd_scaletable[i][j] = ((int8_t)j) * scale; snd_scaletable[i][j] = ((j < 128) ? j : j - 256) * scale; } } diff --git a/source/snd_umx.c b/source/snd_umx.c index 92cb822..a94a7f9 100644 --- a/source/snd_umx.c +++ b/source/snd_umx.c @@ -211,7 +211,7 @@ static int read_typname(fshandle_t *f, const struct upkg_hdr *hdr, FS_fseek(f, hdr->name_offset + l, SEEK_SET); FS_fread(buf, 1, 63, f); if (hdr->file_version >= 64) { - s = *(signed char *)buf; /* numchars *including* terminator */ + s = *(int8_t *)buf; /* numchars *including* terminator */ if (s <= 0 || s > 64) return -1; l += s + 5; /* 1 for buf[0], 4 for int32_t name_flags */ } else { diff --git a/source/wad.h b/source/wad.h index 8838e0e..388dd10 100644 --- a/source/wad.h +++ b/source/wad.h @@ -60,9 +60,9 @@ typedef struct int filepos; int disksize; int size; // uncompressed - char type; - char compression; - char pad1, pad2; + int8_t type; + int8_t compression; + uint8_t pad1, pad2; char name[16]; // must be null terminated } lumpinfo_t;