Tidy up.
authorLaurent Monin <geeqie@norz.org>
Wed, 25 Jun 2008 20:53:52 +0000 (20:53 +0000)
committerLaurent Monin <geeqie@norz.org>
Wed, 25 Jun 2008 20:53:52 +0000 (20:53 +0000)
src/collect-io.c
src/exif.c
src/exiv2.cc
src/filecache.c
src/filedata.c
src/thumb.c
src/utilops.c

index 8a48bec..715b4e0 100644 (file)
@@ -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;
index dd58bb0..444af80 100644 (file)
@@ -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);
                }
index 855d6b4..b49c61f 100644 (file)
@@ -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<Exiv2::Exifdatum *>(metadatum)))
+               if ((exifdatum = dynamic_cast<Exiv2::Exifdatum *>(metadatum)))
                        str << *exifdatum;
                else if ((iptcdatum = dynamic_cast<Exiv2::Iptcdatum *>(metadatum)))
                        str << *iptcdatum;
index e2ccb0a..2d9374d 100644 (file)
@@ -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;
index 7fd064c..1e4875d 100644 (file)
@@ -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;
index 5642724..bba2f78 100644 (file)
@@ -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;
index 8a9d0e7..2ed2786 100644 (file)
@@ -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;