[Bf-blender-cvs] [9ba948a4859] master: Cleanup: style, use braces for blenlib

Campbell Barton noreply at git.blender.org
Wed Mar 27 03:23:51 CET 2019


Commit: 9ba948a4859da3308033fa6dc54f74433d7e6a21
Author: Campbell Barton
Date:   Wed Mar 27 13:16:10 2019 +1100
Branches: master
https://developer.blender.org/rB9ba948a4859da3308033fa6dc54f74433d7e6a21

Cleanup: style, use braces for blenlib

===================================================================

M	source/blender/blenlib/intern/BLI_args.c
M	source/blender/blenlib/intern/BLI_dial_2d.c
M	source/blender/blenlib/intern/BLI_dynstr.c
M	source/blender/blenlib/intern/BLI_filelist.c
M	source/blender/blenlib/intern/BLI_ghash.c
M	source/blender/blenlib/intern/BLI_kdopbvh.c
M	source/blender/blenlib/intern/BLI_linklist.c
M	source/blender/blenlib/intern/BLI_timer.c
M	source/blender/blenlib/intern/DLRB_tree.c
M	source/blender/blenlib/intern/boxpack_2d.c
M	source/blender/blenlib/intern/convexhull_2d.c
M	source/blender/blenlib/intern/dynlib.c
M	source/blender/blenlib/intern/easing.c
M	source/blender/blenlib/intern/edgehash.c
M	source/blender/blenlib/intern/expr_pylike_eval.c
M	source/blender/blenlib/intern/fileops.c
M	source/blender/blenlib/intern/freetypefont.c
M	source/blender/blenlib/intern/gsqueue.c
M	source/blender/blenlib/intern/hash_md5.c
M	source/blender/blenlib/intern/jitter_2d.c
M	source/blender/blenlib/intern/lasso_2d.c
M	source/blender/blenlib/intern/listbase.c
M	source/blender/blenlib/intern/math_base.c
M	source/blender/blenlib/intern/math_base_inline.c
M	source/blender/blenlib/intern/math_color.c
M	source/blender/blenlib/intern/math_color_inline.c
M	source/blender/blenlib/intern/math_geom.c
M	source/blender/blenlib/intern/math_geom_inline.c
M	source/blender/blenlib/intern/math_interp.c
M	source/blender/blenlib/intern/math_matrix.c
M	source/blender/blenlib/intern/math_rotation.c
M	source/blender/blenlib/intern/math_solvers.c
M	source/blender/blenlib/intern/math_statistics.c
M	source/blender/blenlib/intern/math_vector.c
M	source/blender/blenlib/intern/noise.c
M	source/blender/blenlib/intern/path_util.c
M	source/blender/blenlib/intern/polyfill_2d.c
M	source/blender/blenlib/intern/rand.c
M	source/blender/blenlib/intern/rct.c
M	source/blender/blenlib/intern/scanfill.c
M	source/blender/blenlib/intern/smallhash.c
M	source/blender/blenlib/intern/sort.c
M	source/blender/blenlib/intern/sort_utils.c
M	source/blender/blenlib/intern/storage.c
M	source/blender/blenlib/intern/string.c
M	source/blender/blenlib/intern/string_utf8.c
M	source/blender/blenlib/intern/string_utils.c
M	source/blender/blenlib/intern/task.c
M	source/blender/blenlib/intern/threads.c
M	source/blender/blenlib/intern/uvproject.c
M	source/blender/blenlib/intern/voronoi_2d.c
M	source/blender/blenlib/intern/winstuff.c
M	source/blender/blenlib/intern/winstuff_dir.c

===================================================================

diff --git a/source/blender/blenlib/intern/BLI_args.c b/source/blender/blenlib/intern/BLI_args.c
index dbd609d914a..61619bc114b 100644
--- a/source/blender/blenlib/intern/BLI_args.c
+++ b/source/blender/blenlib/intern/BLI_args.c
@@ -71,8 +71,9 @@ static uint case_strhash(const void *ptr)
 	uint i = 0;
 	unsigned char c;
 
-	while ( (c = tolower(*s++)) )
+	while ((c = tolower(*s++))) {
 		i = i * 37 + c;
+	}
 
 	return i;
 }
@@ -150,8 +151,9 @@ static bArgDoc *internalDocs(struct bArgs *ba, const char *short_arg, const char
 
 	d = MEM_callocN(sizeof(bArgDoc), "bArgDoc");
 
-	if (doc == NULL)
+	if (doc == NULL) {
 		doc = NO_DOCS;
+	}
 
 	d->short_arg = short_arg;
 	d->long_arg = long_arg;
@@ -200,11 +202,13 @@ void BLI_argsAddCase(struct bArgs *ba, int pass,
 {
 	bArgDoc *d = internalDocs(ba, short_arg, long_arg, doc);
 
-	if (short_arg)
+	if (short_arg) {
 		internalAdd(ba, short_arg, pass, short_case, cb, data, d);
+	}
 
-	if (long_arg)
+	if (long_arg) {
 		internalAdd(ba, long_arg, pass, long_case, cb, data, d);
+	}
 }
 
 void BLI_argsAdd(struct bArgs *ba, int pass,
@@ -216,12 +220,15 @@ void BLI_argsAdd(struct bArgs *ba, int pass,
 
 static void internalDocPrint(bArgDoc *d)
 {
-	if (d->short_arg && d->long_arg)
+	if (d->short_arg && d->long_arg) {
 		printf("%s or %s", d->short_arg, d->long_arg);
-	else if (d->short_arg)
+	}
+	else if (d->short_arg) {
 		printf("%s", d->short_arg);
-	else if (d->long_arg)
+	}
+	else if (d->long_arg) {
 		printf("%s", d->long_arg);
+	}
 
 	printf(" %s\n\n", d->documentation);
 }
@@ -284,8 +291,9 @@ void BLI_argsParse(struct bArgs *ba, int pass, BA_ArgCallback default_cb, void *
 				}
 				else if (retval == -1) {
 					if (a) {
-						if (a->key->pass != -1)
+						if (a->key->pass != -1) {
 							ba->passes[i] = pass;
+						}
 					}
 					break;
 				}
diff --git a/source/blender/blenlib/intern/BLI_dial_2d.c b/source/blender/blenlib/intern/BLI_dial_2d.c
index 882d239aa4b..dd983fe7f8f 100644
--- a/source/blender/blenlib/intern/BLI_dial_2d.c
+++ b/source/blender/blenlib/intern/BLI_dial_2d.c
@@ -88,10 +88,12 @@ float BLI_dial_angle(Dial *dial, const float current_position[2])
 		if ((angle * dial->last_angle < 0.0f) &&
 		    (fabsf(dial->last_angle) > (float)M_PI_2))
 		{
-			if (dial->last_angle < 0.0f)
+			if (dial->last_angle < 0.0f) {
 				dial->rotations--;
-			else
+			}
+			else {
 				dial->rotations++;
+			}
 		}
 		dial->last_angle = angle;
 
diff --git a/source/blender/blenlib/intern/BLI_dynstr.c b/source/blender/blenlib/intern/BLI_dynstr.c
index 98682101c65..ef45d7b2a47 100644
--- a/source/blender/blenlib/intern/BLI_dynstr.c
+++ b/source/blender/blenlib/intern/BLI_dynstr.c
@@ -112,10 +112,12 @@ void BLI_dynstr_append(DynStr *__restrict ds, const char *cstr)
 	memcpy(dse->str, cstr, cstrlen + 1);
 	dse->next = NULL;
 
-	if (!ds->last)
+	if (!ds->last) {
 		ds->last = ds->elems = dse;
-	else
+	}
+	else {
 		ds->last = ds->last->next = dse;
+	}
 
 	ds->curlen += cstrlen;
 }
@@ -137,10 +139,12 @@ void BLI_dynstr_nappend(DynStr *__restrict ds, const char *cstr, int len)
 	dse->str[cstrlen] = '\0';
 	dse->next = NULL;
 
-	if (!ds->last)
+	if (!ds->last) {
 		ds->last = ds->elems = dse;
-	else
+	}
+	else {
 		ds->last = ds->last->next = dse;
+	}
 
 	ds->curlen += cstrlen;
 }
@@ -154,10 +158,12 @@ void BLI_dynstr_vappendf(DynStr *__restrict ds, const char *__restrict format, v
 
 	while (1) {
 		va_list args_cpy;
-		if (len == sizeof(fixedmessage))
+		if (len == sizeof(fixedmessage)) {
 			message = fixedmessage;
-		else
+		}
+		else {
 			message = MEM_callocN(sizeof(char) * len, "BLI_dynstr_appendf");
+		}
 
 		/* cant reuse the same args, so work on a copy */
 		va_copy(args_cpy, args);
@@ -167,8 +173,9 @@ void BLI_dynstr_vappendf(DynStr *__restrict ds, const char *__restrict format, v
 		if (retval == -1) {
 			/* -1 means not enough space, but on windows it may also mean
 			 * there is a formatting error, so we impose a maximum length */
-			if (message != fixedmessage)
+			if (message != fixedmessage) {
 				MEM_freeN(message);
+			}
 			message = NULL;
 
 			len *= 2;
@@ -179,22 +186,25 @@ void BLI_dynstr_vappendf(DynStr *__restrict ds, const char *__restrict format, v
 		}
 		else if (retval >= len) {
 			/* in C99 the actual length required is returned */
-			if (message != fixedmessage)
+			if (message != fixedmessage) {
 				MEM_freeN(message);
+			}
 			message = NULL;
 
 			/* retval doesn't include \0 terminator */
 			len = retval + 1;
 		}
-		else
+		else {
 			break;
+		}
 	}
 
 	if (message) {
 		BLI_dynstr_append(ds, message);
 
-		if (message != fixedmessage)
+		if (message != fixedmessage) {
 			MEM_freeN(message);
+		}
 	}
 }
 
@@ -217,10 +227,12 @@ void BLI_dynstr_appendf(DynStr *__restrict ds, const char *__restrict format, ..
 	 * va_start/va_end have to be called for each vsnprintf call */
 
 	while (1) {
-		if (len == sizeof(fixedmessage))
+		if (len == sizeof(fixedmessage)) {
 			message = fixedmessage;
-		else
+		}
+		else {
 			message = MEM_callocN(sizeof(char) * (len), "BLI_dynstr_appendf");
+		}
 
 		va_start(args, format);
 		retval = vsnprintf(message, len, format, args);
@@ -229,8 +241,9 @@ void BLI_dynstr_appendf(DynStr *__restrict ds, const char *__restrict format, ..
 		if (retval == -1) {
 			/* -1 means not enough space, but on windows it may also mean
 			 * there is a formatting error, so we impose a maximum length */
-			if (message != fixedmessage)
+			if (message != fixedmessage) {
 				MEM_freeN(message);
+			}
 			message = NULL;
 
 			len *= 2;
@@ -241,22 +254,25 @@ void BLI_dynstr_appendf(DynStr *__restrict ds, const char *__restrict format, ..
 		}
 		else if (retval >= len) {
 			/* in C99 the actual length required is returned */
-			if (message != fixedmessage)
+			if (message != fixedmessage) {
 				MEM_freeN(message);
+			}
 			message = NULL;
 
 			/* retval doesn't include \0 terminator */
 			len = retval + 1;
 		}
-		else
+		else {
 			break;
+		}
 	}
 
 	if (message) {
 		BLI_dynstr_append(ds, message);
 
-		if (message != fixedmessage)
+		if (message != fixedmessage) {
 			MEM_freeN(message);
+		}
 	}
 }
 
diff --git a/source/blender/blenlib/intern/BLI_filelist.c b/source/blender/blenlib/intern/BLI_filelist.c
index 8cbba2103d3..243c7d95da1 100644
--- a/source/blender/blenlib/intern/BLI_filelist.c
+++ b/source/blender/blenlib/intern/BLI_filelist.c
@@ -65,28 +65,36 @@ static int bli_compare(struct direntry *entry1, struct direntry *entry2)
 
 	/* directories come before non-directories */
 	if (S_ISDIR(entry1->type)) {
-		if (S_ISDIR(entry2->type) == 0) return (-1);
+		if (S_ISDIR(entry2->type) == 0) {
+			return -1;
+		}
 	}
 	else {
-		if (S_ISDIR(entry2->type)) return (1);
+		if (S_ISDIR(entry2->type)) {
+			return 1;
+		}
 	}
 	/* non-regular files come after regular files */
 	if (S_ISREG(entry1->type)) {
-		if (S_ISREG(entry2->type) == 0) return (-1);
+		if (S_ISREG(entry2->type) == 0) {
+			return -1;
+		}
 	}
 	else {
-		if (S_ISREG(entry2->type)) return (1);
+		if (S_ISREG(entry2->type)) {
+			return 1;
+		}
 	}
 	/* arbitrary, but consistent, ordering of different types of non-regular files */
-	if ((entry1->type & S_IFMT) < (entry2->type & S_IFMT)) return (-1);
-	if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) return (1);
+	if ((entry1->type & S_IFMT) < (entry2->type & S_IFMT)) { return -1; }
+	if ((entry1->type & S_IFMT) > (entry2->type & S_IFMT)) { return  1; }
 
 	/* OK, now we know their S_IFMT fields are the same, go on to a name comparison */
 	/* make sure "." and ".." are always first */
-	if (FILENAME_IS_CURRENT(entry1->relname)) return (-1);
-	if (FILENAME_IS_CURRENT(entry2->relname)) return (1);
-	if (FILENAME_IS_PARENT(entry1->relname)) return (-1);
-	if (FILENAME_IS_PARENT(entry2->relname)) return (1);
+	if (FILENAME_IS_CURRENT(entry1->relname)) { return -1; }
+	if (FILENAME_IS_CURRENT(entry2->relname)) { return  1; }
+	if (FILENAME_IS_PARENT(entry1->relname))  { return -1; }
+	if (FILENAME_IS_PARENT(entry2->relname))  { return  1; }
 
 	return (BLI_natstrcmp(entry1->relname, entry2->relname));
 }
@@ -159,8 +167,9 @@ static void bli_builddir(struct BuildDirCtx *dir_ctx, const char *dirname)
 				}
 			}
 
-			if (dir_ctx->files == NULL)
+			if (dir_ctx->files == NULL) {
 				dir_ctx->files = (struct direntry *)MEM_mallocN(newnum * sizeof(struct direntry), __func__);
+			}
 
 			if (dir_ctx->files) {
 				struct dirlink * dlink = (struct dirlink *) dirbase.first;
@@ -253,7 +262,9 @@ void BLI_filelist_entry_size_to_string(
 
 	if (size > 1024.0) {
 		const char **u;
-		for (u = compact ? units_compact : units, size /= 1024.0; size > 1024.0 && *(u + 1); u++, size /= 1024.0);
+		for (u = compact ? units_compact : units, size /= 1024.0; size > 1024.0 && *(u + 1); u++, size /= 1024.0) {
+			/* pass */
+		}
 		fmt =  size > 100.0 ? "%.0f %s" : (size > 10.0 ? "%.1f %s" : "%.2f %s");
 		unit = *u;
 	}
@@ -284,18 +295,30 @@ void BLI_filelist_entry_mode_to_string(
 	BLI_strncpy(r_mode2, types[(mode & 0070) >> 3], sizeof(*r_mode2) * FILELIST_DIRENTRY_MODE_LEN);
 	BLI_strncpy(r_mode3, types[(mode & 0007)],      sizeof(*r_mode3) * FILELIST_DIRENTRY_MODE_LEN);
 
-	if (((mode & S_ISGID) == S_ISGID) && (r_mode2[2] == '-')) r_mode2[2] = 'l';
+	if (((mode & S_ISGID) == S_ISGID) && (r_mode2[2] == '-')) {
+		r_mode2[2] = 'l';
+	}
 
 	if (mode & (S_ISUID | S_ISGID)) {
-		if (r_mode1[2] == 'x') r_mode1[2] = 's';
-		else r_mode1[2] = 'S';
+		if (r_mode1[2] == 'x') {
+			r_mode1[2] = 's';
+		}
+		else {
+			r_mode1[2] = 'S';
+		}
 
-		if (r_mode2[2] == 'x') r_mode2[2] = 's';
+		if (r_mode2[2] == 'x') {
+			r_mode2[2] = 's';
+		}
 	}
 
 	if (mode & S_ISVTX) {
-		if (r_mode3[2] == 'x') r_mode3[2] = 't';
-		else r_mode3[2] = 'T';
+		if (r_mode3[2] == 'x') {
+			r_mode3[2] = 't';
+		}
+		else {
+			r_mode3[2] = 'T';
+		}
 	}
 #endif
 }
diff --git a/source/blender/blenlib/intern/BLI_ghash.c b/source/blender/blenlib/intern/BLI_ghash.c
index fc432c8c8b7..af3a7a4f68a 100644
--- a/source/blender/blenlib/intern/BLI_ghash.c
+++ b/source/blender/blenlib/intern/BLI_ghash.c
@@ -241,7 +241,9 @@ static void ghash_buckets_resize(GHash *gh, const uint nbuckets)
 				const unsigned bucket_index = ghash_bucket_index(gh, i);
 				BLI_assert(!buckets_old[i]

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list