Ticket #3547: mc-3547-treestore.c-cleanup-bit-fields-warnings.patch

File mc-3547-treestore.c-cleanup-bit-fields-warnings.patch, 2.4 KB (added by and, 8 years ago)

what more preferred? using bit fields and saving bytes or using gboolean for FALSE/TRUE state values

  • src/filemanager/treestore.c

    From 16d025d04d65074acf284f2c13b30ce680ca2f1b Mon Sep 17 00:00:00 2001
    From: Andreas Mohr <and@gmx.li>
    Date: Sun, 13 Dec 2015 16:52:24 +0000
    Subject: [PATCH] treestore.c cleanup bit fields warnings
    
    treestore.c:89:16: warning: conversion to 'unsigned char:1' from 'int' may alter its value [-Wconversion]
    treestore.c:288:42: warning: conversion to 'unsigned char:1' from 'int' may alter its value [-Wconversion]
    treestore.c:302:34: warning: conversion to 'unsigned char:1' from 'int' may alter its value [-Wconversion]
    
    what more preferred? using bit fields and saving bytes or using gboolean for FALSE/TRUE state values
    
    Signed-off-by: Andreas Mohr <and@gmx.li>
    ---
     src/filemanager/treestore.c | 10 +++++-----
     1 file changed, 5 insertions(+), 5 deletions(-)
    
    diff --git a/src/filemanager/treestore.c b/src/filemanager/treestore.c
    index 093c99f..21445e4 100644
    a b static tree_entry *tree_store_add_entry (const vfs_path_t * name); 
    8484/* --------------------------------------------------------------------------------------------- */ 
    8585 
    8686static void 
    87 tree_store_dirty (int state) 
     87tree_store_dirty (unsigned int state) 
    8888{ 
    89     ts.dirty = state; 
     89    ts.dirty = state & (1 << 0); 
    9090} 
    9191 
    9292/* --------------------------------------------------------------------------------------------- */ 
    tree_store_load_from (char *name) 
    247247        while (fgets (buffer, MC_MAXPATHLEN, file)) 
    248248        { 
    249249            tree_entry *e; 
    250             int scanned; 
     250            unsigned int scanned; 
    251251            char *lc_name; 
    252252 
    253253            /* Skip invalid records */ 
    tree_store_load_from (char *name) 
    285285                            tmp_vpath = vfs_path_from_str (oldname); 
    286286                            e = tree_store_add_entry (tmp_vpath); 
    287287                            vfs_path_free (tmp_vpath); 
    288                             e->scanned = scanned; 
     288                            e->scanned = scanned & (1 << 0); 
    289289                        } 
    290290                        vfs_path_free (vpath); 
    291291                    } 
    tree_store_load_from (char *name) 
    299299                if (vfs_file_is_local (vpath)) 
    300300                { 
    301301                    e = tree_store_add_entry (vpath); 
    302                     e->scanned = scanned; 
     302                    e->scanned = scanned & (1 << 0); 
    303303                } 
    304304                vfs_path_free (vpath); 
    305305                strcpy (oldname, lc_name);