Cleanup: style, use braces

Add braces for modules already using braces almost everywhere.
This commit is contained in:
Campbell Barton 2019-04-22 12:20:14 +10:00
parent b102472551
commit 7d6a9b5517
12 changed files with 155 additions and 78 deletions

View File

@ -373,8 +373,9 @@ void AbcGenericMeshWriter::setIsAnimated(bool is_animated)
void AbcGenericMeshWriter::do_write()
{
/* We have already stored a sample for this object. */
if (!m_first_frame && !m_is_animated)
if (!m_first_frame && !m_is_animated) {
return;
}
bool needsfree;
struct Mesh *mesh = getFinalMesh(needsfree);
@ -387,12 +388,14 @@ void AbcGenericMeshWriter::do_write()
writeMesh(mesh);
}
if (needsfree)
if (needsfree) {
freeEvaluatedMesh(mesh);
}
}
catch (...) {
if (needsfree)
if (needsfree) {
freeEvaluatedMesh(mesh);
}
throw;
}
}

View File

@ -787,8 +787,9 @@ static void import_endjob(void *user_data)
/* It's possible that cancellation occurred between the creation of
* the reader and the creation of the Blender object. */
if (ob == NULL)
if (ob == NULL) {
continue;
}
BKE_id_free_us(data->bmain, ob);
}

View File

@ -70,11 +70,13 @@ int BLI_file_gzip(const char *from, const char *to)
/* level 1 is very close to 3 (the default) in terms of file size,
* but about twice as fast, best use for speedy saving - campbell */
gzfile = BLI_gzopen(to, "wb1");
if (gzfile == NULL)
if (gzfile == NULL) {
return -1;
}
file = BLI_open(from, O_BINARY | O_RDONLY, 0);
if (file == -1)
if (file == -1) {
return -2;
}
while (1) {
readsize = read(file, buffer, sizeof(buffer));
@ -84,8 +86,9 @@ int BLI_file_gzip(const char *from, const char *to)
fprintf(stderr, "Error reading file %s: %s.\n", from, strerror(errno));
break;
}
else if (readsize == 0)
else if (readsize == 0) {
break; /* done reading */
}
if (gzwrite(gzfile, buffer, readsize) <= 0) {
rval = -1; /* error happened in writing */
@ -946,8 +949,9 @@ static int move_callback_pre(const char *from, const char *to)
{
int ret = rename(from, to);
if (ret)
if (ret) {
return copy_callback_pre(from, to);
}
return RecursiveOp_Callback_StopRecurs;
}
@ -956,8 +960,9 @@ static int move_single_file(const char *from, const char *to)
{
int ret = rename(from, to);
if (ret)
if (ret) {
return copy_single_file(from, to);
}
return RecursiveOp_Callback_OK;
}

View File

@ -108,8 +108,9 @@ static void fill_locales(void)
continue; /* Comment or void... */
}
t = atoi(str);
if (t >= num_locales)
if (t >= num_locales) {
num_locales = t + 1;
}
num_locales_menu++;
line = line->next;
}
@ -261,8 +262,9 @@ void BLT_lang_set(const char *str)
const char *short_locale = str ? str : LOCALE(ulang);
const char *short_locale_utf8 = NULL;
if ((U.transopts & USER_DOTRANSLATE) == 0)
if ((U.transopts & USER_DOTRANSLATE) == 0) {
return;
}
/* We want to avoid locales like '.UTF-8'! */
if (short_locale[0]) {
@ -331,36 +333,45 @@ void BLT_lang_locale_explode(const char *locale,
if (language || language_variant) {
if (m1 || m2) {
_t = m1 ? BLI_strdupn(locale, m1 - locale) : BLI_strdupn(locale, m2 - locale);
if (language)
if (language) {
*language = _t;
}
}
else if (language) {
*language = BLI_strdup(locale);
}
}
if (country) {
if (m1)
if (m1) {
*country = m2 ? BLI_strdupn(m1 + 1, m2 - (m1 + 1)) : BLI_strdup(m1 + 1);
else
}
else {
*country = NULL;
}
}
if (variant) {
if (m2)
if (m2) {
*variant = BLI_strdup(m2 + 1);
else
}
else {
*variant = NULL;
}
}
if (language_country) {
if (m1)
if (m1) {
*language_country = m2 ? BLI_strdupn(locale, m2 - locale) : BLI_strdup(locale);
else
}
else {
*language_country = NULL;
}
}
if (language_variant) {
if (m2)
if (m2) {
*language_variant = m1 ? BLI_strdupcat(_t, m2) : BLI_strdup(locale);
else
}
else {
*language_variant = NULL;
}
}
if (_t && !language) {
MEM_freeN(_t);

View File

@ -82,12 +82,15 @@ static char *trim(char *str)
return str;
}
for (i = 0; i < len && ELEM(str[0], ' ', '\t', '\n'); str++, i++)
;
for (i = 0; i < len && ELEM(str[0], ' ', '\t', '\n'); str++, i++) {
/* pass */
}
char *end = &str[len - 1 - i];
for (i = len; i > 0 && ELEM(end[0], ' ', '\t', '\n'); end--, i--)
;
for (i = len; i > 0 && ELEM(end[0], ' ', '\t', '\n'); end--, i--) {
/* pass */
}
end[1] = '\0';
return str;

View File

@ -2990,11 +2990,13 @@ static void adjust_offsets(BevelParams *bp, BMesh *bm)
/* find and process chains and cycles of unvisited BoundVerts that have eon set */
/* note: for repeatability, iterate over all verts of mesh rather than over ghash'ed BMVerts */
BM_ITER_MESH (bmv, &iter, bm, BM_VERTS_OF_MESH) {
if (!BM_elem_flag_test(bmv, BM_ELEM_TAG))
if (!BM_elem_flag_test(bmv, BM_ELEM_TAG)) {
continue;
}
bv = bvcur = find_bevvert(bp, bmv);
if (!bv)
if (!bv) {
continue;
}
vanchor = bv->vmesh->boundstart;
do {
if (vanchor->visited || !vanchor->eon) {
@ -3068,8 +3070,9 @@ static void adjust_offsets(BevelParams *bp, BMesh *bm)
BM_ITER_MESH (bmv, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(bmv, BM_ELEM_TAG)) {
bv = find_bevvert(bp, bmv);
if (bv)
if (bv) {
build_boundary(bp, bv, false);
}
}
}
}
@ -6357,11 +6360,13 @@ static void bevel_limit_offset(BevelParams *bp, BMesh *bm)
limited_offset = bp->offset;
BM_ITER_MESH (bmv, &iter, bm, BM_VERTS_OF_MESH) {
if (!BM_elem_flag_test(bmv, BM_ELEM_TAG))
if (!BM_elem_flag_test(bmv, BM_ELEM_TAG)) {
continue;
}
bv = find_bevvert(bp, bmv);
if (!bv)
if (!bv) {
continue;
}
for (i = 0; i < bv->edgecount; i++) {
eh = &bv->edges[i];
if (bp->vertex_only) {
@ -6387,11 +6392,13 @@ static void bevel_limit_offset(BevelParams *bp, BMesh *bm)
*/
offset_factor = limited_offset / bp->offset;
BM_ITER_MESH (bmv, &iter, bm, BM_VERTS_OF_MESH) {
if (!BM_elem_flag_test(bmv, BM_ELEM_TAG))
if (!BM_elem_flag_test(bmv, BM_ELEM_TAG)) {
continue;
}
bv = find_bevvert(bp, bmv);
if (!bv)
if (!bv) {
continue;
}
for (i = 0; i < bv->edgecount; i++) {
eh = &bv->edges[i];
eh->offset_l_spec *= offset_factor;
@ -6500,8 +6507,9 @@ void BM_mesh_bevel(BMesh *bm,
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
bv = find_bevvert(&bp, v);
if (bv)
if (bv) {
build_boundary(&bp, bv, true);
}
}
}
}
@ -6534,8 +6542,9 @@ void BM_mesh_bevel(BMesh *bm,
BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
if (BM_elem_flag_test(v, BM_ELEM_TAG)) {
bv = find_bevvert(&bp, v);
if (bv)
if (bv) {
bevel_extend_edge_data(bv);
}
}
}

View File

@ -80,8 +80,9 @@ int main(int argc, char **argv)
argv_len = (int)strlen(argv[1]);
for (i = 0; i < argv_len; i++) {
if (argv[1][i] == '.')
if (argv[1][i] == '.') {
argv[1][i] = '_';
}
}
fpout = fopen(argv[2], "w");

View File

@ -122,8 +122,9 @@ static int deg_debug_node_color_index(const Node *node)
return 5;
case NodeType::OPERATION: {
OperationNode *op_node = (OperationNode *)node;
if (op_node->is_noop())
if (op_node->is_noop()) {
return 8;
}
break;
}
@ -485,16 +486,19 @@ static bool deg_debug_graphviz_is_owner(const Node *node, const Node *other)
switch (node->get_class()) {
case NodeClass::COMPONENT: {
ComponentNode *comp_node = (ComponentNode *)node;
if (comp_node->owner == other)
if (comp_node->owner == other) {
return true;
}
break;
}
case NodeClass::OPERATION: {
OperationNode *op_node = (OperationNode *)node;
if (op_node->owner == other)
if (op_node->owner == other) {
return true;
else if (op_node->owner->owner == other)
}
else if (op_node->owner->owner == other) {
return true;
}
break;
}
default:

View File

@ -237,10 +237,12 @@ void DEG_stats_simple(const Depsgraph *graph,
tot_rels += time_source->inlinks.size();
}
if (r_relations)
if (r_relations) {
*r_relations = tot_rels;
if (r_outer)
}
if (r_outer) {
*r_outer = tot_outer;
}
}
}

View File

@ -4731,8 +4731,9 @@ void DRW_mesh_batch_cache_free_old(Mesh *me, int ctime)
{
MeshBatchCache *cache = me->runtime.batch_cache;
if (cache == NULL)
if (cache == NULL) {
return;
}
if (mesh_cd_layers_type_equal(cache->cd_used_over_time, cache->cd_used)) {
cache->lastmatch = ctime;

View File

@ -977,8 +977,9 @@ void DRW_cache_free_old_batches(Main *bmain)
static int lasttime = 0;
int ctime = (int)PIL_check_seconds_timer();
if (U.vbotimeout == 0 || (ctime - lasttime) < U.vbocollectrate || ctime == lasttime)
if (U.vbotimeout == 0 || (ctime - lasttime) < U.vbocollectrate || ctime == lasttime) {
return;
}
lasttime = ctime;

View File

@ -96,8 +96,9 @@ void imb_freemipmapImBuf(ImBuf *ibuf)
/* any free rect frees mipmaps to be sure, creation is in render on first request */
void imb_freerectfloatImBuf(ImBuf *ibuf)
{
if (ibuf == NULL)
if (ibuf == NULL) {
return;
}
if (ibuf->rect_float && (ibuf->mall & IB_rectfloat)) {
MEM_freeN(ibuf->rect_float);
@ -113,11 +114,13 @@ void imb_freerectfloatImBuf(ImBuf *ibuf)
/* any free rect frees mipmaps to be sure, creation is in render on first request */
void imb_freerectImBuf(ImBuf *ibuf)
{
if (ibuf == NULL)
if (ibuf == NULL) {
return;
}
if (ibuf->rect && (ibuf->mall & IB_rect))
if (ibuf->rect && (ibuf->mall & IB_rect)) {
MEM_freeN(ibuf->rect);
}
ibuf->rect = NULL;
imb_freemipmapImBuf(ibuf);
@ -129,8 +132,9 @@ void imb_freetilesImBuf(ImBuf *ibuf)
{
int tx, ty;
if (ibuf == NULL)
if (ibuf == NULL) {
return;
}
if (ibuf->tiles && (ibuf->mall & IB_tiles)) {
for (ty = 0; ty < ibuf->ytiles; ty++) {
@ -151,11 +155,13 @@ void imb_freetilesImBuf(ImBuf *ibuf)
static void freeencodedbufferImBuf(ImBuf *ibuf)
{
if (ibuf == NULL)
if (ibuf == NULL) {
return;
}
if (ibuf->encodedbuffer && (ibuf->mall & IB_mem))
if (ibuf->encodedbuffer && (ibuf->mall & IB_mem)) {
MEM_freeN(ibuf->encodedbuffer);
}
ibuf->encodedbuffer = NULL;
ibuf->encodedbuffersize = 0;
@ -165,11 +171,13 @@ static void freeencodedbufferImBuf(ImBuf *ibuf)
void IMB_freezbufImBuf(ImBuf *ibuf)
{
if (ibuf == NULL)
if (ibuf == NULL) {
return;
}
if (ibuf->zbuf && (ibuf->mall & IB_zbuf))
if (ibuf->zbuf && (ibuf->mall & IB_zbuf)) {
MEM_freeN(ibuf->zbuf);
}
ibuf->zbuf = NULL;
ibuf->mall &= ~IB_zbuf;
@ -177,11 +185,13 @@ void IMB_freezbufImBuf(ImBuf *ibuf)
void IMB_freezbuffloatImBuf(ImBuf *ibuf)
{
if (ibuf == NULL)
if (ibuf == NULL) {
return;
}
if (ibuf->zbuf_float && (ibuf->mall & IB_zbuffloat))
if (ibuf->zbuf_float && (ibuf->mall & IB_zbuffloat)) {
MEM_freeN(ibuf->zbuf_float);
}
ibuf->zbuf_float = NULL;
ibuf->mall &= ~IB_zbuffloat;
@ -255,8 +265,9 @@ ImBuf *IMB_makeSingleUser(ImBuf *ibuf)
bool addzbufImBuf(ImBuf *ibuf)
{
if (ibuf == NULL)
if (ibuf == NULL) {
return false;
}
IMB_freezbufImBuf(ibuf);
@ -271,8 +282,9 @@ bool addzbufImBuf(ImBuf *ibuf)
bool addzbuffloatImBuf(ImBuf *ibuf)
{
if (ibuf == NULL)
if (ibuf == NULL) {
return false;
}
IMB_freezbuffloatImBuf(ibuf);
@ -287,13 +299,15 @@ bool addzbuffloatImBuf(ImBuf *ibuf)
bool imb_addencodedbufferImBuf(ImBuf *ibuf)
{
if (ibuf == NULL)
if (ibuf == NULL) {
return false;
}
freeencodedbufferImBuf(ibuf);
if (ibuf->encodedbuffersize == 0)
if (ibuf->encodedbuffersize == 0) {
ibuf->encodedbuffersize = 10000;
}
ibuf->encodedsize = 0;
@ -311,8 +325,9 @@ bool imb_enlargeencodedbufferImBuf(ImBuf *ibuf)
unsigned int newsize, encodedsize;
void *newbuffer;
if (ibuf == NULL)
if (ibuf == NULL) {
return false;
}
if (ibuf->encodedbuffersize < ibuf->encodedsize) {
printf("%s: error in parameters\n", __func__);
@ -320,12 +335,14 @@ bool imb_enlargeencodedbufferImBuf(ImBuf *ibuf)
}
newsize = 2 * ibuf->encodedbuffersize;
if (newsize < 10000)
if (newsize < 10000) {
newsize = 10000;
}
newbuffer = MEM_mallocN(newsize, __func__);
if (newbuffer == NULL)
if (newbuffer == NULL) {
return false;
}
if (ibuf->encodedbuffer) {
memcpy(newbuffer, ibuf->encodedbuffer, ibuf->encodedsize);
@ -362,11 +379,13 @@ void *imb_alloc_pixels(
bool imb_addrectfloatImBuf(ImBuf *ibuf)
{
if (ibuf == NULL)
if (ibuf == NULL) {
return false;
}
if (ibuf->rect_float)
if (ibuf->rect_float) {
imb_freerectfloatImBuf(ibuf); /* frees mipmap too, hrm */
}
ibuf->channels = 4;
if ((ibuf->rect_float = imb_alloc_pixels(ibuf->x, ibuf->y, 4, sizeof(float), __func__))) {
@ -381,13 +400,15 @@ bool imb_addrectfloatImBuf(ImBuf *ibuf)
/* question; why also add zbuf? */
bool imb_addrectImBuf(ImBuf *ibuf)
{
if (ibuf == NULL)
if (ibuf == NULL) {
return false;
}
/* Don't call imb_freerectImBuf, it frees mipmaps,
* this call is used only too give float buffers display. */
if (ibuf->rect && (ibuf->mall & IB_rect))
if (ibuf->rect && (ibuf->mall & IB_rect)) {
MEM_freeN(ibuf->rect);
}
ibuf->rect = NULL;
if ((ibuf->rect = imb_alloc_pixels(ibuf->x, ibuf->y, 4, sizeof(unsigned char), __func__))) {
@ -411,8 +432,9 @@ struct ImBuf *IMB_allocFromBuffer(const unsigned int *rect,
{
ImBuf *ibuf = NULL;
if (!(rect || rectf))
if (!(rect || rectf)) {
return NULL;
}
ibuf = IMB_allocImBuf(w, h, 32, 0);
@ -432,13 +454,16 @@ struct ImBuf *IMB_allocFromBuffer(const unsigned int *rect,
bool imb_addtilesImBuf(ImBuf *ibuf)
{
if (ibuf == NULL)
if (ibuf == NULL) {
return false;
}
if (!ibuf->tiles)
if (!ibuf->tiles) {
if ((ibuf->tiles = MEM_callocN(sizeof(unsigned int *) * ibuf->xtiles * ibuf->ytiles,
"imb_tiles")))
"imb_tiles"))) {
ibuf->mall |= IB_tiles;
}
}
return (ibuf->tiles != NULL);
}
@ -511,37 +536,47 @@ ImBuf *IMB_dupImBuf(const ImBuf *ibuf1)
int flags = 0;
int a, x, y;
if (ibuf1 == NULL)
if (ibuf1 == NULL) {
return NULL;
}
if (ibuf1->rect)
if (ibuf1->rect) {
flags |= IB_rect;
if (ibuf1->rect_float)
}
if (ibuf1->rect_float) {
flags |= IB_rectfloat;
if (ibuf1->zbuf)
}
if (ibuf1->zbuf) {
flags |= IB_zbuf;
if (ibuf1->zbuf_float)
}
if (ibuf1->zbuf_float) {
flags |= IB_zbuffloat;
}
x = ibuf1->x;
y = ibuf1->y;
ibuf2 = IMB_allocImBuf(x, y, ibuf1->planes, flags);
if (ibuf2 == NULL)
if (ibuf2 == NULL) {
return NULL;
}
if (flags & IB_rect)
if (flags & IB_rect) {
memcpy(ibuf2->rect, ibuf1->rect, ((size_t)x) * y * sizeof(int));
}
if (flags & IB_rectfloat)
if (flags & IB_rectfloat) {
memcpy(
ibuf2->rect_float, ibuf1->rect_float, ((size_t)ibuf1->channels) * x * y * sizeof(float));
}
if (flags & IB_zbuf)
if (flags & IB_zbuf) {
memcpy(ibuf2->zbuf, ibuf1->zbuf, ((size_t)x) * y * sizeof(int));
}
if (flags & IB_zbuffloat)
if (flags & IB_zbuffloat) {
memcpy(ibuf2->zbuf_float, ibuf1->zbuf_float, ((size_t)x) * y * sizeof(float));
}
if (ibuf1->encodedbuffer) {
ibuf2->encodedbuffersize = ibuf1->encodedbuffersize;
@ -602,8 +637,9 @@ static MEM_CacheLimiterC **get_imbuf_cache_limiter(void)
{
static MEM_CacheLimiterC *c = NULL;
if (!c)
if (!c) {
c = new_MEM_CacheLimiter(imbuf_cache_destructor, NULL);
}
return &c;
}