From d29cd729b404fc3901d862214231ef514f855aa5 Mon Sep 17 00:00:00 2001 From: Laurent Monin Date: Wed, 25 Jun 2008 20:53:52 +0000 Subject: [PATCH] Tidy up. --- src/collect-io.c | 2 +- src/exif.c | 10 ++++++---- src/exiv2.cc | 5 ++--- src/filecache.c | 10 +++++++--- src/filedata.c | 2 +- src/thumb.c | 8 ++++---- src/utilops.c | 2 +- 7 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/collect-io.c b/src/collect-io.c index 8a48bec8..715b4e07 100644 --- a/src/collect-io.c +++ b/src/collect-io.c @@ -43,7 +43,7 @@ static gint scan_geometry(gchar *buffer, gint *x, gint *y, gint *w, gint *h) { gint nx, ny, nw, nh; - if(sscanf(buffer, "%d %d %d %d", &nx, &ny, &nw, &nh) != 4) return FALSE; + if (sscanf(buffer, "%d %d %d %d", &nx, &ny, &nw, &nh) != 4) return FALSE; *x = nx; *y = ny; diff --git a/src/exif.c b/src/exif.c index dd58bb0a..444af80f 100644 --- a/src/exif.c +++ b/src/exif.c @@ -1104,7 +1104,8 @@ static gint map_file(const gchar *path, void **mapping, int *size) int fd; struct stat fs; - if ((fd = open(path, O_RDONLY)) == -1) + fd = open(path, O_RDONLY); + if (fd == -1) { perror(path); return -1; @@ -1119,7 +1120,8 @@ static gint map_file(const gchar *path, void **mapping, int *size) *size = fs.st_size; - if ((*mapping = mmap(0, *size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0)) == MAP_FAILED) + *mapping = mmap(0, *size, PROT_READ|PROT_WRITE, MAP_PRIVATE, fd, 0); + if (*mapping == MAP_FAILED) { perror(path); close(fd); @@ -1180,8 +1182,8 @@ ExifData *exif_read(gchar *path, gchar *sidecar_path) exif->items = NULL; exif->current = NULL; - if ((res = exif_jpeg_parse(exif, (unsigned char *)f, size, - ExifKnownMarkersList)) == -2) + res = exif_jpeg_parse(exif, (unsigned char *)f, size, ExifKnownMarkersList); + if (res == -2) { res = exif_tiff_parse(exif, (unsigned char *)f, size, ExifKnownMarkersList); } diff --git a/src/exiv2.cc b/src/exiv2.cc index 855d6b44..b49c61fb 100644 --- a/src/exiv2.cc +++ b/src/exiv2.cc @@ -356,7 +356,7 @@ char *exif_item_get_data(ExifItem *item, guint *data_len) try { if (!item) return 0; Exiv2::Metadatum *md = (Exiv2::Metadatum *)item; - if(data_len) *data_len = md->size(); + if (data_len) *data_len = md->size(); char *data = (char *)g_malloc(md->size()); long res = md->copy((Exiv2::byte *)data, Exiv2::littleEndian /* should not matter */); g_assert(res == md->size()); @@ -454,8 +454,7 @@ gchar *exif_item_get_data_as_text(ExifItem *item) #if EXIV2_TEST_VERSION(0,16,0) Exiv2::Xmpdatum *xmpdatum; #endif - - if ((exifdatum = dynamic_cast(metadatum))) + if ((exifdatum = dynamic_cast(metadatum))) str << *exifdatum; else if ((iptcdatum = dynamic_cast(metadatum))) str << *iptcdatum; diff --git a/src/filecache.c b/src/filecache.c index e2ccb0ac..2d9374dc 100644 --- a/src/filecache.c +++ b/src/filecache.c @@ -50,7 +50,9 @@ FileCacheData *file_cache_new(FileCacheReleaseFunc release, gulong max_size) gint file_cache_get(FileCacheData *fc, FileData *fd) { GList *work; - if ((work = g_list_find_custom(fc->list, fd, file_cache_entry_compare_cb))) + + work = g_list_find_custom(fc->list, fd, file_cache_entry_compare_cb); + if (work) { fc->list = g_list_remove_link(fc->list, work); fc->list = g_list_concat(work, fc->list); @@ -86,7 +88,9 @@ void file_cache_put(FileCacheData *fc, FileData *fd, gulong size) { GList *work; FileCacheEntry *fe; - if ((work = g_list_find_custom(fc->list, fd, file_cache_entry_compare_cb))) + + work = g_list_find_custom(fc->list, fd, file_cache_entry_compare_cb); + if (work) { /* entry already exists, move it to the beginning */ fc->list = g_list_remove_link(fc->list, work); @@ -127,7 +131,7 @@ void file_cache_dump(FileCacheData *fc) DEBUG_1("cache dump: max size:%ld size:%ld", fc->max_size, fc->size); - while(work) + while (work) { FileCacheEntry *fe = work->data; work = work->next; diff --git a/src/filedata.c b/src/filedata.c index 7fd064c7..1e4875db 100644 --- a/src/filedata.c +++ b/src/filedata.c @@ -428,7 +428,7 @@ FileData *file_data_new_simple(const gchar *path_utf8) FileData *file_data_add_sidecar_file(FileData *target, FileData *sfd) { sfd->parent = target; - if(!g_list_find(target->sidecar_files, sfd)) + if (!g_list_find(target->sidecar_files, sfd)) target->sidecar_files = g_list_prepend(target->sidecar_files, sfd); file_data_increment_version(sfd); /* increments both sfd and target */ return target; diff --git a/src/thumb.c b/src/thumb.c index 56427240..bba2f782 100644 --- a/src/thumb.c +++ b/src/thumb.c @@ -592,10 +592,10 @@ static guchar *load_xv_thumbnail(gchar *filename, gint *widthp, gint *heightp) gint width, height, depth; file = fopen(filename, "rt"); - if(!file) return NULL; + if (!file) return NULL; fgets(buffer, XV_BUFFER, file); - if(strncmp(buffer, "P7 332", 6) != 0) + if (strncmp(buffer, "P7 332", 6) != 0) { fclose(file); return NULL; @@ -603,7 +603,7 @@ static guchar *load_xv_thumbnail(gchar *filename, gint *widthp, gint *heightp) while (fgets(buffer, XV_BUFFER, file) && buffer[0] == '#') /* do_nothing() */; - if(sscanf(buffer, "%d %d %d", &width, &height, &depth) != 3) + if (sscanf(buffer, "%d %d %d", &width, &height, &depth) != 3) { fclose(file); return NULL; @@ -665,7 +665,7 @@ static GdkPixbuf *get_xv_thumbnail(gchar *thumb_filename, gint max_w, gint max_h packed_data = load_xv_thumbnail(thumb_name, &width, &height); g_free(thumb_name); - if(packed_data) + if (packed_data) { guchar *rgb_data; GdkPixbuf *pixbuf; diff --git a/src/utilops.c b/src/utilops.c index 8a9d0e77..2ed2786a 100644 --- a/src/utilops.c +++ b/src/utilops.c @@ -1191,7 +1191,7 @@ static void file_util_disable_grouping_sc_list(GList *list) { GList *work = list; - while(work) + while (work) { FileData *fd = work->data; work = work->next; -- 2.20.1