[fix] fix compile warning

This commit is contained in:
dijunkun
2025-04-11 16:09:11 +08:00
parent 824d9243cc
commit 62d14587cd
4 changed files with 23 additions and 25 deletions

View File

@@ -270,7 +270,7 @@ STBIWDEF void stbi_flip_vertically_on_write(int flip_boolean);
#define STBIW_ASSERT(x) assert(x)
#endif
#define STBIW_UCHAR(x) (unsigned char)((x)&0xff)
#define STBIW_UCHAR(x) (unsigned char)((x) & 0xff)
#ifdef STB_IMAGE_WRITE_STATIC
static int stbi_write_png_compression_level = 8;
@@ -816,8 +816,8 @@ static int stbi_write_hdr_core(stbi__write_context *s, int x, int y, int comp,
sprintf_s(buffer, sizeof(buffer),
"EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x);
#else
len = sprintf(buffer, "EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n",
y, x);
len = snprintf(buffer, sizeof(buffer),
"EXPOSURE= 1.0000000000000\n\n-Y %d +X %d\n", y, x);
#endif
s->func(s->context, buffer, len);
@@ -857,7 +857,7 @@ STBIWDEF int stbi_write_hdr(char const *filename, int x, int y, int comp,
#ifndef STBIW_ZLIB_COMPRESS
// stretchy buffer; stbiw__sbpush() == vector<>::push_back() -- stbiw__sbcount()
// == vector<>::size()
#define stbiw__sbraw(a) ((int *)(void *)(a)-2)
#define stbiw__sbraw(a) ((int *)(void *)(a) - 2)
#define stbiw__sbm(a) stbiw__sbraw(a)[0]
#define stbiw__sbn(a) stbiw__sbraw(a)[1]
@@ -931,9 +931,9 @@ static unsigned int stbiw__zhash(unsigned char *data) {
#define stbiw__zlib_huffa(b, c) stbiw__zlib_add(stbiw__zlib_bitrev(b, c), c)
// default huffman tables
#define stbiw__zlib_huff1(n) stbiw__zlib_huffa(0x30 + (n), 8)
#define stbiw__zlib_huff2(n) stbiw__zlib_huffa(0x190 + (n)-144, 9)
#define stbiw__zlib_huff3(n) stbiw__zlib_huffa(0 + (n)-256, 7)
#define stbiw__zlib_huff4(n) stbiw__zlib_huffa(0xc0 + (n)-280, 8)
#define stbiw__zlib_huff2(n) stbiw__zlib_huffa(0x190 + (n) - 144, 9)
#define stbiw__zlib_huff3(n) stbiw__zlib_huffa(0 + (n) - 256, 7)
#define stbiw__zlib_huff4(n) stbiw__zlib_huffa(0xc0 + (n) - 280, 8)
#define stbiw__zlib_huff(n) \
((n) <= 143 ? stbiw__zlib_huff1(n) \
: (n) <= 255 ? stbiw__zlib_huff2(n) \
@@ -951,7 +951,7 @@ STBIWDEF unsigned char *stbi_zlib_compress(unsigned char *data, int data_len,
#ifdef STBIW_ZLIB_COMPRESS
// user provided a zlib compress implementation, use that
return STBIW_ZLIB_COMPRESS(data, data_len, out_len, quality);
#else // use builtin
#else // use builtin
static unsigned short lengthc[] = {
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27,
31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 259};
@@ -1024,12 +1024,10 @@ STBIWDEF unsigned char *stbi_zlib_compress(unsigned char *data, int data_len,
if (bestloc) {
int d = (int)(data + i - bestloc); // distance back
STBIW_ASSERT(d <= 32767 && best <= 258);
for (j = 0; best > lengthc[j + 1] - 1; ++j)
;
for (j = 0; best > lengthc[j + 1] - 1; ++j);
stbiw__zlib_huff(j + 257);
if (lengtheb[j]) stbiw__zlib_add(best - lengthc[j], lengtheb[j]);
for (j = 0; d > distc[j + 1] - 1; ++j)
;
for (j = 0; d > distc[j + 1] - 1; ++j);
stbiw__zlib_add(stbiw__zlib_bitrev(j, 5), 5);
if (disteb[j]) stbiw__zlib_add(d - distc[j], disteb[j]);
i += best;