[Bf-blender-cvs] [6cc09d006af] master: Cleanup: style, use braces for blenloader
Campbell Barton
noreply at git.blender.org
Mon Apr 22 13:15:25 CEST 2019
Commit: 6cc09d006af4a89cea14485e8e3896bd38a80e4b
Author: Campbell Barton
Date: Mon Apr 22 09:13:00 2019 +1000
Branches: master
https://developer.blender.org/rB6cc09d006af4a89cea14485e8e3896bd38a80e4b
Cleanup: style, use braces for blenloader
===================================================================
M source/blender/blenloader/intern/readblenentry.c
M source/blender/blenloader/intern/readfile.c
M source/blender/blenloader/intern/undofile.c
M source/blender/blenloader/intern/versioning_250.c
M source/blender/blenloader/intern/versioning_260.c
M source/blender/blenloader/intern/versioning_270.c
M source/blender/blenloader/intern/versioning_280.c
M source/blender/blenloader/intern/versioning_legacy.c
M source/blender/blenloader/intern/versioning_userdef.c
M source/blender/blenloader/intern/writefile.c
===================================================================
diff --git a/source/blender/blenloader/intern/readblenentry.c b/source/blender/blenloader/intern/readblenentry.c
index 8067a322490..5e4fe4ce269 100644
--- a/source/blender/blenloader/intern/readblenentry.c
+++ b/source/blender/blenloader/intern/readblenentry.c
@@ -99,8 +99,9 @@ void BLO_blendhandle_print_sizes(BlendHandle *bh, void *fp)
fprintf(fp, "[\n");
for (bhead = blo_bhead_first(fd); bhead; bhead = blo_bhead_next(fd, bhead)) {
- if (bhead->code == ENDB)
+ if (bhead->code == ENDB) {
break;
+ }
else {
const short *sp = fd->filesdna->structs[bhead->SDNAnr];
const char *name = fd->filesdna->types[sp[0]];
@@ -150,8 +151,9 @@ LinkNode *BLO_blendhandle_get_datablock_names(BlendHandle *bh, int ofblocktype,
BLI_linklist_prepend(&names, strdup(idname + 2));
tot++;
}
- else if (bhead->code == ENDB)
+ else if (bhead->code == ENDB) {
break;
+ }
}
*tot_names = tot;
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 706f28eb312..16e8c040fda 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -416,8 +416,9 @@ static OldNewMap *oldnewmap_new(void)
static void oldnewmap_insert(OldNewMap *onm, const void *oldaddr, void *newaddr, int nr)
{
- if (oldaddr == NULL || newaddr == NULL)
+ if (oldaddr == NULL || newaddr == NULL) {
return;
+ }
if (UNLIKELY(onm->nentries == ENTRIES_CAPACITY(onm))) {
oldnewmap_increase_size(onm);
@@ -438,24 +439,29 @@ void blo_do_versions_oldnewmap_insert(OldNewMap *onm, const void *oldaddr, void
static void *oldnewmap_lookup_and_inc(OldNewMap *onm, const void *addr, bool increase_users)
{
OldNew *entry = oldnewmap_lookup_entry(onm, addr);
- if (entry == NULL)
+ if (entry == NULL) {
return NULL;
- if (increase_users)
+ }
+ if (increase_users) {
entry->nr++;
+ }
return entry->newp;
}
/* for libdata, OldNew.nr has ID code, no increment */
static void *oldnewmap_liblookup(OldNewMap *onm, const void *addr, const void *lib)
{
- if (addr == NULL)
+ if (addr == NULL) {
return NULL;
+ }
ID *id = oldnewmap_lookup_and_inc(onm, addr, false);
- if (id == NULL)
+ if (id == NULL) {
return NULL;
- if (!lib || id->lib)
+ }
+ if (!lib || id->lib) {
return id;
+ }
return NULL;
}
@@ -548,8 +554,9 @@ void blo_split_main(ListBase *mainlist, Main *main)
mainlist->first = mainlist->last = main;
main->next = NULL;
- if (BLI_listbase_is_empty(&main->libraries))
+ if (BLI_listbase_is_empty(&main->libraries)) {
return;
+ }
/* (Library.temp_index -> Main), lookup table */
const uint lib_main_array_len = BLI_listbase_count(&main->libraries);
@@ -593,8 +600,9 @@ static void read_file_version(FileData *fd, Main *main)
main->minsubversionfile = fg->minsubversion;
MEM_freeN(fg);
}
- else if (bhead->code == ENDB)
+ else if (bhead->code == ENDB) {
break;
+ }
}
}
if (main->curlib) {
@@ -659,8 +667,9 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
const char *libname = (m->curlib) ? m->curlib->filepath : m->name;
if (BLI_path_cmp(name1, libname) == 0) {
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("blo_find_main: found library %s\n", libname);
+ }
return m;
}
}
@@ -680,8 +689,9 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
read_file_version(fd, m);
- if (G.debug & G_DEBUG)
+ if (G.debug & G_DEBUG) {
printf("blo_find_main: added new lib %s\n", filepath);
+ }
return m;
}
@@ -694,8 +704,9 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab
static void switch_endian_bh4(BHead4 *bhead)
{
/* the ID_.. codes */
- if ((bhead->code & 0xFFFF) == 0)
+ if ((bhead->code & 0xFFFF) == 0) {
bhead->code >>= 16;
+ }
if (bhead->code != ENDB) {
BLI_endian_switch_int32(&bhead->len);
@@ -707,8 +718,9 @@ static void switch_endian_bh4(BHead4 *bhead)
static void switch_endian_bh8(BHead8 *bhead)
{
/* the ID_.. codes */
- if ((bhead->code & 0xFFFF) == 0)
+ if ((bhead->code & 0xFFFF) == 0) {
bhead->code >>= 16;
+ }
if (bhead->code != ENDB) {
BLI_endian_switch_int32(&bhead->len);
@@ -1046,7 +1058,7 @@ static bool read_file_dna(FileData *fd, const char **r_error_message)
/* We can't use read_global because this needs 'DNA1' to be decoded,
* however the first 4 chars are _always_ the subversion. */
FileGlobal *fg = (void *)&bhead[1];
- BLI_STATIC_ASSERT(offsetof(FileGlobal, subvstr) == 0, "Must be first: subvstr");
+ BLI_STATIC_ASSERT(offsetof(FileGlobal, subvstr) == 0, "Must be first: subvstr")
char num[5];
memcpy(num, fg->subvstr, 4);
num[4] = 0;
@@ -1069,8 +1081,9 @@ static bool read_file_dna(FileData *fd, const char **r_error_message)
return false;
}
}
- else if (bhead->code == ENDB)
+ else if (bhead->code == ENDB) {
break;
+ }
}
*r_error_message = "Missing DNA block";
@@ -1183,8 +1196,9 @@ static int fd_read_from_memfile(FileData *filedata, void *buffer, uint size)
static MemFileChunk *chunk = NULL;
size_t chunkoffset, readsize, totread;
- if (size == 0)
+ if (size == 0) {
return 0;
+ }
if (seek != (size_t)filedata->file_offset) {
chunk = filedata->memfile->chunks.first;
@@ -1223,8 +1237,9 @@ static int fd_read_from_memfile(FileData *filedata, void *buffer, uint size)
/* data can be spread over multiple chunks, so clamp size
* to within this chunk, and then it will read further in
* the next chunk */
- if (chunkoffset + readsize > chunk->size)
+ if (chunkoffset + readsize > chunk->size) {
readsize = chunk->size - chunkoffset;
+ }
memcpy(POINTER_OFFSET(buffer, totread), chunk->buf + chunkoffset, readsize);
totread += readsize;
@@ -1428,8 +1443,9 @@ static int fd_read_gzip_from_memory_init(FileData *fd)
fd->strm.zalloc = Z_NULL;
fd->strm.zfree = Z_NULL;
- if (inflateInit2(&fd->strm, (16 + MAX_WBITS)) != Z_OK)
+ if (inflateInit2(&fd->strm, (16 + MAX_WBITS)) != Z_OK) {
return 0;
+ }
fd->read = fd_read_gzip_from_memory;
@@ -1456,8 +1472,9 @@ FileData *blo_filedata_from_memory(const void *mem, int memsize, ReportList *rep
return NULL;
}
}
- else
+ else {
fd->read = fd_read_from_memory;
+ }
fd->flags |= FD_FLAGS_NOT_MY_BUFFER;
@@ -1517,29 +1534,40 @@ void blo_filedata_free(FileData *fd)
}
#endif
- if (fd->filesdna)
+ if (fd->filesdna) {
DNA_sdna_free(fd->filesdna);
- if (fd->compflags)
+ }
+ if (fd->compflags) {
MEM_freeN((void *)fd->compflags);
+ }
- if (fd->datamap)
+ if (fd->datamap) {
oldnewmap_free(fd->datamap);
- if (fd->globmap)
+ }
+ if (fd->globmap) {
oldnewmap_free(fd->globmap);
- if (fd->imamap)
+ }
+ if (fd->imamap) {
oldnewmap_free(fd->imamap);
- if (fd->movieclipmap)
+ }
+ if (fd->movieclipmap) {
oldnewmap_free(fd->movieclipmap);
- if (fd->scenemap)
+ }
+ if (fd->scenemap) {
oldnewmap_free(fd->scenemap);
- if (fd->soundmap)
+ }
+ if (fd->soundmap) {
oldnewmap_free(fd->soundmap);
- if (fd->packedmap)
+ }
+ if (fd->packedmap) {
oldnewmap_free(fd->packedmap);
- if (fd->libmap && !(fd->flags & FD_FLAGS_NOT_MY_LIBMAP))
+ }
+ if (fd->libmap && !(fd->flags & FD_FLAGS_NOT_MY_LIBMAP)) {
oldnewmap_free(fd->libmap);
- if (fd->bheadmap)
+ }
+ if (fd->bheadmap) {
MEM_freeN(fd->bheadmap);
+ }
#ifdef USE_GHASH_BHEAD
if (fd->bhead_idname_hash) {
@@ -1702,38 +1730,43 @@ static void *newglobadr(FileData *fd, const void *adr) /* direct datablocks with
static void *newimaadr(FileData *fd, const void *adr) /* used to restore image data after undo */
{
- if (fd->imamap && adr)
+ if (fd->imamap && adr) {
return oldnewmap_lookup_and_inc(fd->imamap, adr, true);
+ }
return NULL;
}
static void *newsceadr(FileData *fd, const void *adr) /* used to restore scene data after undo */
{
- if (fd->scenemap && adr)
+ if (fd->scenemap && adr) {
return oldnewmap_lookup_and_inc(fd->scenemap, adr, true);
+ }
return NULL;
}
static void *newmclipadr(FileData *fd,
const void *adr) /* used to restore movie clip data after undo */
{
- if (fd->movieclipmap && adr)
+ if (fd->movieclipmap && adr) {
return oldnewmap_lookup_and_inc(fd->movieclipmap, adr, true);
+ }
return NULL;
}
static void *newsoundadr(FileData *fd, const void *adr) /* used to restore sound data after undo */
{
- if (fd->soundmap && adr)
+ if (fd->soundmap && adr) {
return oldnewmap_lookup_and_inc(fd->soundmap, adr, true);
+ }
return NULL;
}
static void *newpackedadr(FileData *fd,
const void *adr) /* used to restore packed data after undo */
{
- if (fd->packedmap && adr)
+ if (fd->packedmap && adr) {
return oldnewmap_lookup_and_inc(fd->packedmap, adr, true);
+ }
return oldnewmap_lookup_and_inc(fd->datamap, adr, true);
}
@@ -1784,8 +1817,9 @@ static void change_link_placeholder_to_real_ID_pointer_fd(FileData *fd, const vo
if (old == entry->newp && entry->nr == ID_LINK_PLACEHOLDER) {
entry->newp = new;
- if (new)
+ if (new) {
entry->nr = GS(((ID *)new)->name);
+ }
}
}
}
@@ -1800,10 +1834,12 @@ static void change_link_placeholder_to_real_ID_pointer(ListBase *mainlist,
for (mainptr = mainlist->first; mainptr; mainptr = mainptr->next) {
FileData *fd;
- if (mainptr->curlib)
+ if (mainptr->curlib) {
fd = mainptr->curlib->filedata;
- else
+ }
+ else {
fd = basefd;
+ }
if (fd) {
change_link_placeholder_to_real_ID_pointer_fd(fd, old, new);
@@ -1850,8 +1886,9 @@ void blo_end_scene_pointer_map(FileData *fd, Main *oldmain)
/* used entries were restored, so we put them to zero */
for (i = 0; i < fd->sc
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list