code cleanup: remove paranoid/invalid NULL checks and also reduce some unneeded size_t -> int conversions.

This commit is contained in:
Campbell Barton 2012-09-15 07:31:17 +00:00
parent b85056cbf4
commit fed6b2bcb7
12 changed files with 15 additions and 15 deletions

@ -159,7 +159,7 @@ static void blf_font_ensure_ascii_table(FontBLF *font)
} \
} (void)0
void blf_font_draw(FontBLF *font, const char *str, unsigned int len)
void blf_font_draw(FontBLF *font, const char *str, size_t len)
{
unsigned int c;
GlyphBLF *g, *g_prev = NULL;
@ -191,7 +191,7 @@ void blf_font_draw(FontBLF *font, const char *str, unsigned int len)
}
/* faster version of blf_font_draw, ascii only for view dimensions */
void blf_font_draw_ascii(FontBLF *font, const char *str, unsigned int len)
void blf_font_draw_ascii(FontBLF *font, const char *str, size_t len)
{
unsigned char c;
GlyphBLF *g, *g_prev = NULL;

@ -51,8 +51,8 @@ struct FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem
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_draw(struct FontBLF *font, const char *str, unsigned int len);
void blf_font_draw_ascii(struct FontBLF *font, const char *str, unsigned int len);
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);
void blf_font_buffer(struct FontBLF *font, const char *str);
void blf_font_boundbox(struct FontBLF *font, const char *str, struct rctf *box);
void blf_font_width_and_height(struct FontBLF *font, const char *str, float *width, float *height);

@ -129,7 +129,7 @@ void BLF_lang_init(void)
}
/* get LANG/LANGUAGE environment variable */
static void get_language_variable(const char *varname, char *var, int maxlen)
static void get_language_variable(const char *varname, char *var, const size_t maxlen)
{
char *env = getenv(varname);
@ -149,7 +149,7 @@ static void get_language_variable(const char *varname, char *var, int maxlen)
/* get language to be used based on locale(which might be empty when using default language) and
* LANG environment variable
*/
static void get_language(const char *locale, const char *lang, char *language, int maxlen)
static void get_language(const char *locale, const char *lang, char *language, const size_t maxlen)
{
if (locale[0]) {
BLI_strncpy(language, locale, maxlen);

@ -3288,7 +3288,7 @@ void BKE_object_groups_clear(Scene *scene, Base *base, Object *object)
{
Group *group = NULL;
BLI_assert(base->object == object);
BLI_assert((base == NULL) || (base->object == object));
if (scene && base == NULL) {
base = BKE_scene_base_find(scene, object);

@ -3070,7 +3070,6 @@ int setcurr_tab_spaces(Text *text, int space)
const char *comm = "#";
const char indent = (text->flags & TXT_TABSTOSPACES) ? ' ' : '\t';
static const char *back_words[] = {"return", "break", "continue", "pass", "yield", NULL};
if (!text) return 0;
if (!text->curl) return 0;
while (text->curl->line[i] == indent) {

@ -667,7 +667,7 @@ void heat_bone_weighting(Object *ob, Mesh *me, float (*verts)[3], int numsource,
*err_str = NULL;
/* count triangles and create mask */
if ((use_face_sel = (me->editflag & ME_EDIT_PAINT_MASK) != 0) ||
if ((use_face_sel = ((me->editflag & ME_EDIT_PAINT_MASK) != 0)) ||
(use_vert_sel = ((me->editflag & ME_EDIT_VERT_SEL) != 0)))
{
mask = MEM_callocN(sizeof(int) * me->totvert, "heat_bone_weighting mask");

@ -728,7 +728,7 @@ static int pose_select_grouped_exec(bContext *C, wmOperator *op)
short changed = 0;
/* sanity check */
if (ELEM(NULL, ob, ob->pose))
if (ob->pose == NULL)
return OPERATOR_CANCELLED;
/* selection types

@ -851,7 +851,7 @@ void UI_view2d_totRect_set_resize(View2D *v2d, int width, int height, int resize
if (scroll & V2D_SCROLL_VERTICAL)
height -= V2D_SCROLL_HEIGHT;
if (ELEM3(0, v2d, width, height)) {
if (ELEM(0, width, height)) {
if (G.debug & G_DEBUG)
printf("Error: View2D totRect set exiting: v2d=%p width=%d height=%d\n", (void *)v2d, width, height); // XXX temp debug info
return;

@ -1221,7 +1221,7 @@ void GPU_begin_object_materials(View3D *v3d, RegionView3D *rv3d, Scene *scene, O
* - object transparency off: for glsl we draw both in a single pass, and
* for solid we don't use transparency at all. */
GMS.use_alpha_pass = (do_alpha_after != NULL);
GMS.is_alpha_pass = (v3d && v3d->transp);
GMS.is_alpha_pass = (v3d->transp != FALSE);
if (GMS.use_alpha_pass)
*do_alpha_after = FALSE;

@ -62,7 +62,7 @@ void IMB_metadata_free(struct ImBuf *img);
* \param len - length of value buffer allocated by user.
* \return - 1 (true) if ImageInfo present and value for the key found, 0 (false) otherwise
*/
int IMB_metadata_get_field(struct ImBuf *img, const char *key, char *value, int len);
int IMB_metadata_get_field(struct ImBuf *img, const char *key, char *value, const size_t len);
/** set user data in the ImMetaData struct, which has to be allocated with IMB_metadata_create
* before calling this function.

@ -63,7 +63,7 @@ void IMB_metadata_free(struct ImBuf *img)
}
}
int IMB_metadata_get_field(struct ImBuf *img, const char *key, char *field, int len)
int IMB_metadata_get_field(struct ImBuf *img, const char *key, char *field, const size_t len)
{
ImMetaData *info;
int retval = 0;

@ -119,7 +119,8 @@ typedef struct MLoopUV {
#define MLOOPUV_PINNED 4
/* at the moment alpha is abused for vertex painting
* and not used for transparency, note that red and blue are swapped */
* and not used for transparency,
* note that red and blue are _not_ swapped, as they are with #MCol */
typedef struct MLoopCol {
char r, g, b, a;
} MLoopCol;