Cleanup: Blenloader, Clang-Tidy else-after-return fixes

This addresses warnings from Clang-Tidy's `readability-else-after-return`
rule in the `source/blender/blenloader` module.

No functional changes.
This commit is contained in:
Sybren A. Stüvel
2020-08-07 12:31:44 +02:00
parent 1b272a649b
commit fb18e48a84
5 changed files with 70 additions and 80 deletions

View File

@@ -102,28 +102,27 @@ void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp)
if (bhead->code == ENDB) {
break;
}
else {
const short *sp = fd->filesdna->structs[bhead->SDNAnr];
const char *name = fd->filesdna->types[sp[0]];
char buf[4];
buf[0] = (bhead->code >> 24) & 0xFF;
buf[1] = (bhead->code >> 16) & 0xFF;
buf[2] = (bhead->code >> 8) & 0xFF;
buf[3] = (bhead->code >> 0) & 0xFF;
const short *sp = fd->filesdna->structs[bhead->SDNAnr];
const char *name = fd->filesdna->types[sp[0]];
char buf[4];
buf[0] = buf[0] ? buf[0] : ' ';
buf[1] = buf[1] ? buf[1] : ' ';
buf[2] = buf[2] ? buf[2] : ' ';
buf[3] = buf[3] ? buf[3] : ' ';
buf[0] = (bhead->code >> 24) & 0xFF;
buf[1] = (bhead->code >> 16) & 0xFF;
buf[2] = (bhead->code >> 8) & 0xFF;
buf[3] = (bhead->code >> 0) & 0xFF;
fprintf(fp,
"['%.4s', '%s', %d, %ld ],\n",
buf,
name,
bhead->nr,
(long int)(bhead->len + sizeof(BHead)));
}
buf[0] = buf[0] ? buf[0] : ' ';
buf[1] = buf[1] ? buf[1] : ' ';
buf[2] = buf[2] ? buf[2] : ' ';
buf[3] = buf[3] ? buf[3] : ' ';
fprintf(fp,
"['%.4s', '%s', %d, %ld ],\n",
buf,
name,
bhead->nr,
(long int)(bhead->len + sizeof(BHead)));
}
fprintf(fp, "]\n");
}
@@ -268,7 +267,7 @@ LinkNode *BLO_blendhandle_get_linkable_groups(BlendHandle *bh)
if (bhead->code == ENDB) {
break;
}
else if (BKE_idtype_idcode_is_valid(bhead->code)) {
if (BKE_idtype_idcode_is_valid(bhead->code)) {
if (BKE_idtype_idcode_is_linkable(bhead->code)) {
const char *str = BKE_idtype_idcode_to_name(bhead->code);

View File

@@ -373,7 +373,7 @@ static void oldnewmap_insert_or_replace(OldNewMap *onm, OldNew entry)
onm->nentries++;
break;
}
else if (onm->entries[index].oldp == entry.oldp) {
if (onm->entries[index].oldp == entry.oldp) {
onm->entries[index] = entry;
break;
}
@@ -1112,9 +1112,8 @@ static bool read_file_dna(FileData *fd, const char **r_error_message)
return true;
}
else {
return false;
}
return false;
}
else if (bhead->code == ENDB) {
break;
@@ -1156,7 +1155,7 @@ static int *read_file_thumbnail(FileData *fd)
blend_thumb = data;
break;
}
else if (bhead->code != REND) {
if (bhead->code != REND) {
/* Thumbnail is stored in TEST immediately after first REND... */
break;
}
@@ -1373,9 +1372,8 @@ static FileData *blo_filedata_from_file_descriptor(const char *filepath,
errno ? strerror(errno) : TIP_("insufficient content"));
return NULL;
}
else {
BLI_lseek(file, 0, SEEK_SET);
}
BLI_lseek(file, 0, SEEK_SET);
/* Regular file. */
if (memcmp(header, "BLENDER", sizeof(header)) == 0) {
@@ -1397,12 +1395,11 @@ static FileData *blo_filedata_from_file_descriptor(const char *filepath,
errno ? strerror(errno) : TIP_("unknown error reading file"));
return NULL;
}
else {
/* 'seek_fn' is too slow for gzip, don't set it. */
read_fn = fd_read_gzip_from_file;
/* Caller must close. */
file = -1;
}
/* 'seek_fn' is too slow for gzip, don't set it. */
read_fn = fd_read_gzip_from_file;
/* Caller must close. */
file = -1;
}
if (read_fn == NULL) {
@@ -1487,7 +1484,7 @@ static int fd_read_gzip_from_memory(FileData *filedata,
if (err == Z_STREAM_END) {
return 0;
}
else if (err != Z_OK) {
if (err != Z_OK) {
printf("fd_read_gzip_from_memory: zlib error\n");
return 0;
}
@@ -1521,28 +1518,27 @@ FileData *blo_filedata_from_memory(const void *mem, int memsize, ReportList *rep
BKE_report(reports, RPT_WARNING, (mem) ? TIP_("Unable to read") : TIP_("Unable to open"));
return NULL;
}
else {
FileData *fd = filedata_new();
const char *cp = mem;
fd->buffer = mem;
fd->buffersize = memsize;
FileData *fd = filedata_new();
const char *cp = mem;
/* test if gzip */
if (cp[0] == 0x1f && cp[1] == 0x8b) {
if (0 == fd_read_gzip_from_memory_init(fd)) {
blo_filedata_free(fd);
return NULL;
}
fd->buffer = mem;
fd->buffersize = memsize;
/* test if gzip */
if (cp[0] == 0x1f && cp[1] == 0x8b) {
if (0 == fd_read_gzip_from_memory_init(fd)) {
blo_filedata_free(fd);
return NULL;
}
else {
fd->read = fd_read_from_memory;
}
fd->flags |= FD_FLAGS_NOT_MY_BUFFER;
return blo_decode_and_check(fd, reports);
}
else {
fd->read = fd_read_from_memory;
}
fd->flags |= FD_FLAGS_NOT_MY_BUFFER;
return blo_decode_and_check(fd, reports);
}
FileData *blo_filedata_from_memfile(MemFile *memfile,
@@ -1553,16 +1549,15 @@ FileData *blo_filedata_from_memfile(MemFile *memfile,
BKE_report(reports, RPT_WARNING, "Unable to open blend <memory>");
return NULL;
}
else {
FileData *fd = filedata_new();
fd->memfile = memfile;
fd->undo_direction = params->undo_direction;
fd->read = fd_read_from_memfile;
fd->flags |= FD_FLAGS_NOT_MY_BUFFER;
FileData *fd = filedata_new();
fd->memfile = memfile;
fd->undo_direction = params->undo_direction;
return blo_decode_and_check(fd, reports);
}
fd->read = fd_read_from_memfile;
fd->flags |= FD_FLAGS_NOT_MY_BUFFER;
return blo_decode_and_check(fd, reports);
}
void blo_filedata_free(FileData *fd)
@@ -1695,7 +1690,7 @@ bool BLO_library_path_explode(const char *path, char *r_dir, char **r_group, cha
if (BLO_has_bfile_extension(r_dir) && BLI_is_file(r_dir)) {
break;
}
else if (STREQ(r_dir, BLO_EMBEDDED_STARTUP_BLEND)) {
if (STREQ(r_dir, BLO_EMBEDDED_STARTUP_BLEND)) {
break;
}
@@ -9253,17 +9248,16 @@ static bool read_libblock_undo_restore(
*r_id_old = id_old;
return true;
}
else if (id_old != NULL) {
if (id_old != NULL) {
/* Local datablock was changed. Restore at the address of the old datablock. */
DEBUG_PRINTF("read to old existing address\n");
*r_id_old = id_old;
return false;
}
else {
/* Local datablock does not exist in the undo step, so read from scratch. */
DEBUG_PRINTF("read at new address\n");
return false;
}
/* Local datablock does not exist in the undo step, so read from scratch. */
DEBUG_PRINTF("read at new address\n");
return false;
}
/* This routine reads a datablock and its direct data, and advances bhead to
@@ -10034,7 +10028,7 @@ static int verg_bheadsort(const void *v1, const void *v2)
if (x1->old > x2->old) {
return 1;
}
else if (x1->old < x2->old) {
if (x1->old < x2->old) {
return -1;
}
return 0;

View File

@@ -242,7 +242,7 @@ static void do_version_action_editor_properties_region(ListBase *regionbase)
/* already exists */
return;
}
else if (region->regiontype == RGN_TYPE_WINDOW) {
if (region->regiontype == RGN_TYPE_WINDOW) {
/* add new region here */
ARegion *arnew = MEM_callocN(sizeof(ARegion), "buttons for action");
@@ -377,9 +377,8 @@ static char *replace_bbone_easing_rnapath(char *old_path)
MEM_freeN(old_path);
return new_path;
}
else {
return old_path;
}
return old_path;
}
static void do_version_bbone_easing_fcurve_fix(ID *UNUSED(id),

View File

@@ -1447,7 +1447,7 @@ void do_versions_after_linking_cycles(Main *bmain)
if (is_fstop) {
continue;
}
else if (aperture_size > 0.0f) {
if (aperture_size > 0.0f) {
if (camera->type == CAM_ORTHO) {
camera->dof.aperture_fstop = 1.0f / (2.0f * aperture_size);
}

View File

@@ -240,9 +240,8 @@ static bool ww_open_none(WriteWrap *ww, const char *filepath)
FILE_HANDLE(ww) = file;
return true;
}
else {
return false;
}
return false;
}
static bool ww_close_none(WriteWrap *ww)
{
@@ -267,9 +266,8 @@ static bool ww_open_zlib(WriteWrap *ww, const char *filepath)
FILE_HANDLE(ww) = file;
return true;
}
else {
return false;
}
return false;
}
static bool ww_close_zlib(WriteWrap *ww)
{