diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-05-12 10:33:21 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-05-12 10:33:21 +0400 |
commit | 0d36225dd1e8ded87949d157fedb07f9d949cb30 (patch) | |
tree | 7ee65f80bc76e4d7d1e19c0ac352be957b8b69b1 /source | |
parent | 7b707fff56209d8997a2d52dde6f38e67be56c31 (diff) |
quiet sign conversion warnings and reduce sign conversion for BLI_string, and BLF.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenfont/intern/blf_font.c | 5 | ||||
-rw-r--r-- | source/blender/blenfont/intern/blf_glyph.c | 15 | ||||
-rw-r--r-- | source/blender/blenfont/intern/blf_internal.h | 4 | ||||
-rw-r--r-- | source/blender/blenfont/intern/blf_internal_types.h | 14 | ||||
-rw-r--r-- | source/blender/blenlib/intern/string.c | 8 | ||||
-rw-r--r-- | source/blender/blenlib/intern/string_cursor_utf8.c | 4 | ||||
-rw-r--r-- | source/blender/blenlib/intern/string_utf8.c | 34 |
7 files changed, 53 insertions, 31 deletions
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index f2c36475870..3a327d6c794 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -58,6 +58,9 @@ #include "blf_internal_types.h" #include "blf_internal.h" +#ifdef __GNUC__ +# pragma GCC diagnostic error "-Wsign-conversion" +#endif /* freetype2 handle ONLY for this file!. */ static FT_Library ft_lib; @@ -72,7 +75,7 @@ void blf_font_exit(void) FT_Done_FreeType(ft_lib); } -void blf_font_size(FontBLF *font, int size, int dpi) +void blf_font_size(FontBLF *font, unsigned int size, unsigned int dpi) { GlyphCacheBLF *gc; FT_Error err; diff --git a/source/blender/blenfont/intern/blf_glyph.c b/source/blender/blenfont/intern/blf_glyph.c index a6b04b24399..d683378c7ce 100644 --- a/source/blender/blenfont/intern/blf_glyph.c +++ b/source/blender/blenfont/intern/blf_glyph.c @@ -55,8 +55,11 @@ #include "blf_internal_types.h" #include "blf_internal.h" +#ifdef __GNUC__ +# pragma GCC diagnostic error "-Wsign-conversion" +#endif -GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, int size, int dpi) +GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font, unsigned int size, unsigned int dpi) { GlyphCacheBLF *p; @@ -167,18 +170,18 @@ static void blf_glyph_cache_texture(FontBLF *font, GlyphCacheBLF *gc) gc->textures = (GLuint *)realloc((void *)gc->textures, sizeof(GLuint) * gc->ntex); } - gc->p2_width = blf_next_p2((gc->rem_glyphs * gc->max_glyph_width) + (gc->pad * 2)); + gc->p2_width = (int)blf_next_p2((unsigned int)((gc->rem_glyphs * gc->max_glyph_width) + (gc->pad * 2))); if (gc->p2_width > font->max_tex_size) gc->p2_width = font->max_tex_size; i = (int)((gc->p2_width - (gc->pad * 2)) / gc->max_glyph_width); - gc->p2_height = blf_next_p2(((gc->num_glyphs / i) + 1) * gc->max_glyph_height); + gc->p2_height = (int)blf_next_p2((unsigned int)(((gc->num_glyphs / i) + 1) * gc->max_glyph_height)); if (gc->p2_height > font->max_tex_size) gc->p2_height = font->max_tex_size; tot_mem = gc->p2_width * gc->p2_height; - buf = (unsigned char *)MEM_callocN(tot_mem, __func__); + buf = (unsigned char *)MEM_callocN((size_t)tot_mem, __func__); glGenTextures(1, &gc->textures[gc->cur_tex]); glBindTexture(GL_TEXTURE_2D, (font->tex_bind_state = gc->textures[gc->cur_tex])); @@ -269,8 +272,8 @@ GlyphBLF *blf_glyph_add(FontBLF *font, unsigned int index, unsigned int c) } } - g->bitmap = (unsigned char *)MEM_mallocN(g->width * g->height, "glyph bitmap"); - memcpy((void *)g->bitmap, (void *)bitmap.buffer, g->width * g->height); + g->bitmap = (unsigned char *)MEM_mallocN((size_t)(g->width * g->height), "glyph bitmap"); + memcpy((void *)g->bitmap, (void *)bitmap.buffer, (size_t)(g->width * g->height)); } g->advance = ((float)slot->advance.x) / 64.0f; diff --git a/source/blender/blenfont/intern/blf_internal.h b/source/blender/blenfont/intern/blf_internal.h index b1301be46fd..2cb453cdf55 100644 --- a/source/blender/blenfont/intern/blf_internal.h +++ b/source/blender/blenfont/intern/blf_internal.h @@ -50,7 +50,7 @@ struct FontBLF *blf_font_new(const char *name, const char *filename); struct FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, int mem_size); void blf_font_attach_from_mem(struct FontBLF *font, const unsigned char *mem, int mem_size); -void blf_font_size(struct FontBLF *font, int size, int dpi); +void blf_font_size(struct FontBLF *font, unsigned int size, unsigned int dpi); void blf_font_draw(struct FontBLF *font, const char *str, size_t len); void blf_font_draw_ascii(struct FontBLF *font, const char *str, size_t len); int blf_font_draw_mono(struct FontBLF *font, const char *str, size_t len, int cwidth); @@ -62,7 +62,7 @@ float blf_font_height(struct FontBLF *font, const char *str); float blf_font_fixed_width(struct FontBLF *font); void blf_font_free(struct FontBLF *font); -struct GlyphCacheBLF *blf_glyph_cache_find(struct FontBLF *font, int size, int dpi); +struct GlyphCacheBLF *blf_glyph_cache_find(struct FontBLF *font, unsigned int size, unsigned int dpi); struct GlyphCacheBLF *blf_glyph_cache_new(struct FontBLF *font); void blf_glyph_cache_clear(struct FontBLF *font); void blf_glyph_cache_free(struct GlyphCacheBLF *gc); diff --git a/source/blender/blenfont/intern/blf_internal_types.h b/source/blender/blenfont/intern/blf_internal_types.h index de6e70e4461..36294bfe3b5 100644 --- a/source/blender/blenfont/intern/blf_internal_types.h +++ b/source/blender/blenfont/intern/blf_internal_types.h @@ -36,10 +36,10 @@ typedef struct GlyphCacheBLF { struct GlyphCacheBLF *prev; /* font size. */ - int size; + unsigned int size; /* and dpi. */ - int dpi; + unsigned int dpi; /* and the glyphs. */ ListBase bucket[257]; @@ -51,7 +51,7 @@ typedef struct GlyphCacheBLF { GLuint *textures; /* size of the array. */ - int ntex; + unsigned int ntex; /* and the last texture, aka. the current texture. */ int cur_tex; @@ -63,7 +63,7 @@ typedef struct GlyphCacheBLF { int y_offs; /* and the space from one to other. */ - unsigned int pad; + int pad; /* and the bigger glyph in the font. */ int max_glyph_width; @@ -194,16 +194,16 @@ typedef struct FontBLF { rctf clip_rec; /* font dpi (default 72). */ - int dpi; + unsigned int dpi; /* font size. */ - int size; + unsigned int size; /* max texture size. */ int max_tex_size; /* cache current OpenGL texture to save calls into the API */ - int tex_bind_state; + unsigned int tex_bind_state; /* font options. */ int flags; diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index ed11d122e93..aba73936975 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -43,6 +43,10 @@ #include "BLI_utildefines.h" +#ifdef __GNUC__ +# pragma GCC diagnostic error "-Wsign-conversion" +#endif + /** * Duplicates the first \a len bytes of cstring \a str * into a newly mallocN'd string and returns it. \a str @@ -146,7 +150,7 @@ size_t BLI_vsnprintf(char *__restrict buffer, size_t count, const char *__restri BLI_assert(count > 0); BLI_assert(format != NULL); - n = vsnprintf(buffer, count, format, arg); + n = (size_t)vsnprintf(buffer, count, format, arg); if (n != -1 && n < count) { buffer[n] = '\0'; @@ -459,7 +463,7 @@ static int left_number_strcmp(const char *s1, const char *s2, int *tiebreaker) /* same number of digits, compare size of number */ if (numdigit > 0) { - int compare = strncmp(p1, p2, numdigit); + int compare = (int)strncmp(p1, p2, (size_t)numdigit); if (compare != 0) return compare; diff --git a/source/blender/blenlib/intern/string_cursor_utf8.c b/source/blender/blenlib/intern/string_cursor_utf8.c index 38e57cacfb4..a0d3be91607 100644 --- a/source/blender/blenlib/intern/string_cursor_utf8.c +++ b/source/blender/blenlib/intern/string_cursor_utf8.c @@ -36,6 +36,10 @@ #include "BLI_string_cursor_utf8.h" /* own include */ +#ifdef __GNUC__ +# pragma GCC diagnostic error "-Wsign-conversion" +#endif + typedef enum strCursorDelimType { STRCUR_DELIM_NONE, STRCUR_DELIM_ALPHANUMERIC, diff --git a/source/blender/blenlib/intern/string_utf8.c b/source/blender/blenlib/intern/string_utf8.c index 0bb471ddb63..b8dca95ae33 100644 --- a/source/blender/blenlib/intern/string_utf8.c +++ b/source/blender/blenlib/intern/string_utf8.c @@ -41,6 +41,10 @@ #include "BLI_string_utf8.h" /* own include */ +#ifdef __GNUC__ +# pragma GCC diagnostic error "-Wsign-conversion" +#endif + /* from libswish3, originally called u8_isvalid(), * modified to return the index of the bad character (byte index not utf). * http://svn.swish-e.org/libswish3/trunk/src/libswish3/utf8.c r3044 - campbell */ @@ -143,7 +147,7 @@ int BLI_utf8_invalid_strip(char *str, int length) } else { /* strip, keep looking */ - memmove(str, str + 1, length); + memmove(str, str + 1, (size_t)length); tot++; } } @@ -221,7 +225,7 @@ size_t BLI_strncpy_wchar_as_utf8(char *__restrict dst, const wchar_t *__restrict BLI_assert(maxncpy != 0); while (*src && len < maxncpy) { /* XXX can still run over the buffer because utf8 size isn't known :| */ - len += BLI_str_utf8_from_unicode(*src++, dst + len); + len += BLI_str_utf8_from_unicode((unsigned int)*src++, dst + len); } dst[len] = '\0'; @@ -235,7 +239,7 @@ size_t BLI_wstrlen_utf8(const wchar_t *src) size_t len = 0; while (*src) { - len += BLI_str_utf8_from_unicode(*src++, NULL); + len += BLI_str_utf8_from_unicode((unsigned int)*src++, NULL); } return len; @@ -292,7 +296,7 @@ size_t BLI_strnlen_utf8(const char *start, const size_t maxlen) size_t BLI_strncpy_wchar_from_utf8(wchar_t *__restrict dst_w, const char *__restrict src_c, const size_t maxncpy) { - int len = 0; + size_t len = 0; if (dst_w == NULL || src_c == NULL) { return 0; @@ -443,7 +447,8 @@ int BLI_str_utf8_size_safe(const char *p) **/ unsigned int BLI_str_utf8_as_unicode(const char *p) { - int i, mask = 0, len; + int i, len; + unsigned int mask = 0; unsigned int result; const unsigned char c = (unsigned char) *p; @@ -458,7 +463,8 @@ unsigned int BLI_str_utf8_as_unicode(const char *p) /* variant that increments the length */ unsigned int BLI_str_utf8_as_unicode_and_size(const char *__restrict p, size_t *__restrict index) { - int i, mask = 0, len; + int i, len; + unsigned mask = 0; unsigned int result; const unsigned char c = (unsigned char) *p; @@ -466,13 +472,14 @@ unsigned int BLI_str_utf8_as_unicode_and_size(const char *__restrict p, size_t * if (UNLIKELY(len == -1)) return BLI_UTF8_ERR; UTF8_GET (result, p, i, mask, len, BLI_UTF8_ERR); - *index += len; + *index += (size_t)len; return result; } unsigned int BLI_str_utf8_as_unicode_and_size_safe(const char *__restrict p, size_t *__restrict index) { - int i, mask = 0, len; + int i, len; + unsigned int mask = 0; unsigned int result; const unsigned char c = (unsigned char) *p; @@ -482,7 +489,7 @@ unsigned int BLI_str_utf8_as_unicode_and_size_safe(const char *__restrict p, siz return c; } UTF8_GET (result, p, i, mask, len, BLI_UTF8_ERR); - *index += len; + *index += (size_t)len; return result; } @@ -490,7 +497,8 @@ unsigned int BLI_str_utf8_as_unicode_and_size_safe(const char *__restrict p, siz * note, currently this also falls back to latin1 for text drawing. */ unsigned int BLI_str_utf8_as_unicode_step(const char *__restrict p, size_t *__restrict index) { - int i, mask = 0, len; + int i, len; + unsigned int mask = 0; unsigned int result; unsigned char c; @@ -527,7 +535,7 @@ unsigned int BLI_str_utf8_as_unicode_step(const char *__restrict p, size_t *__re UTF8_GET (result, p, i, mask, len, '?'); #endif - *index += len; + *index += (size_t)len; return result; } @@ -547,8 +555,8 @@ size_t BLI_str_utf8_from_unicode(unsigned int c, char *outbuf) { /* If this gets modified, also update the copy in g_string_insert_unichar() */ unsigned int len = 0; - int first; - int i; + unsigned int first; + unsigned int i; if (c < 0x80) { first = 0; |