talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit b2b913e310f2876e5e4686ff5746be8e3c79d455
parent f69f1588a93e4988990617bba6ec03933b081693
Author: wwp <wwp@free.fr>
Date:   Tue, 27 Dec 2016 18:06:11 +0100

Fix compiler warnings when we test enum-based variables for impossible
<0 values.

Diffstat:
Msrc/gtk/gtkunit.c | 3+--
Msrc/passwordstore.c | 33++++++++++++++-------------------
Msrc/stock_pixmap.c | 6+++---
3 files changed, 18 insertions(+), 24 deletions(-)

diff --git a/src/gtk/gtkunit.c b/src/gtk/gtkunit.c @@ -436,8 +436,7 @@ gtk_unit_format_string (const gchar *format, g_return_val_if_fail (format != NULL, NULL); g_return_val_if_fail (unit == CM_UNIT_PERCENT || - (unit >= CM_UNIT_PIXEL && - unit < gtk_unit_get_number_of_units ()), NULL); + (unit < gtk_unit_get_number_of_units ()), NULL); while (i < (sizeof (buffer) - 1) && *format) { diff --git a/src/passwordstore.c b/src/passwordstore.c @@ -45,8 +45,7 @@ static PasswordBlock *_get_block(PasswordBlockType block_type, GSList *item; PasswordBlock *block; - g_return_val_if_fail(block_type >= 0 && block_type < NUM_PWS_TYPES, - NULL); + g_return_val_if_fail(block_type < NUM_PWS_TYPES, NULL); g_return_val_if_fail(block_name != NULL, NULL); for (item = _password_store; item != NULL; item = item->next) { @@ -72,8 +71,7 @@ static PasswordBlock *_new_block(PasswordBlockType block_type, { PasswordBlock *block; - g_return_val_if_fail(block_type >= 0 && block_type < NUM_PWS_TYPES, - NULL); + g_return_val_if_fail(block_type < NUM_PWS_TYPES, NULL); g_return_val_if_fail(block_name != NULL, NULL); /* First check to see if the block doesn't already exist. */ @@ -98,7 +96,7 @@ static PasswordBlock *_new_block(PasswordBlockType block_type, return block; } -/////////////////////////////////////////////////////////////// +/*************************************************************/ /* Stores a password. */ gboolean passwd_store_set(PasswordBlockType block_type, @@ -111,8 +109,7 @@ gboolean passwd_store_set(PasswordBlockType block_type, PasswordBlock *block; gchar *encrypted_password; - g_return_val_if_fail(block_type >= 0 && block_type < NUM_PWS_TYPES, - FALSE); + g_return_val_if_fail(block_type < NUM_PWS_TYPES, FALSE); g_return_val_if_fail(block_name != NULL, FALSE); g_return_val_if_fail(password_id != NULL, FALSE); @@ -127,7 +124,7 @@ gboolean passwd_store_set(PasswordBlockType block_type, password_id, block_type, block_name, (encrypted ? ", already encrypted" : "") ); - // find correct block (create if needed) + /* find correct block (create if needed) */ if ((block = _get_block(block_type, block_name)) == NULL) { /* If caller wants to delete a password, and even its block * doesn't exist, we're done. */ @@ -159,7 +156,7 @@ gboolean passwd_store_set(PasswordBlockType block_type, encrypted_password = g_strdup(p); } - // add encrypted password to the block + /* add encrypted password to the block */ g_hash_table_insert(block->entries, g_strdup(password_id), encrypted_password); @@ -176,21 +173,20 @@ gchar *passwd_store_get(PasswordBlockType block_type, PasswordBlock *block; gchar *encrypted_password, *password; - g_return_val_if_fail(block_type >= 0 && block_type < NUM_PWS_TYPES, - NULL); + g_return_val_if_fail(block_type < NUM_PWS_TYPES, NULL); g_return_val_if_fail(block_name != NULL, NULL); g_return_val_if_fail(password_id != NULL, NULL); debug_print("Getting password '%s' from block (%d/%s)\n", password_id, block_type, block_name); - // find correct block + /* find correct block */ if ((block = _get_block(block_type, block_name)) == NULL) { debug_print("Block (%d/%s) not found.\n", block_type, block_name); return NULL; } - // grab pointer to encrypted password + /* grab pointer to encrypted password */ if ((encrypted_password = g_hash_table_lookup(block->entries, password_id)) == NULL) { debug_print("Password '%s' in block (%d/%s) not found.\n", @@ -198,7 +194,7 @@ gchar *passwd_store_get(PasswordBlockType block_type, return NULL; } - // decrypt password + /* decrypt password */ if ((password = password_decrypt(encrypted_password, NULL)) == NULL) { debug_print("Could not decrypt password '%s' for block (%d/%s).\n", @@ -206,7 +202,7 @@ gchar *passwd_store_get(PasswordBlockType block_type, return NULL; } - // return decrypted password + /* return decrypted password */ return password; } @@ -215,13 +211,12 @@ gboolean passwd_store_delete_block(PasswordBlockType block_type, { PasswordBlock *block; - g_return_val_if_fail(block_type >= 0 && block_type < NUM_PWS_TYPES, - FALSE); + g_return_val_if_fail(block_type < NUM_PWS_TYPES, FALSE); g_return_val_if_fail(block_name != NULL, FALSE); debug_print("Deleting block (%d/%s)\n", block_type, block_name); - // find correct block + /* find correct block */ if ((block = _get_block(block_type, block_name)) == NULL) { debug_print("Block (%d/%s) not found.\n", block_type, block_name); return FALSE; @@ -401,7 +396,7 @@ void passwd_store_read_config(void) PasswordBlock *block = NULL; PasswordBlockType type; - // TODO: passwd_store_clear(); + /* TODO: passwd_store_clear(); */ debug_print("Reading password store from file...\n"); diff --git a/src/stock_pixmap.c b/src/stock_pixmap.c @@ -464,7 +464,7 @@ GtkWidget *stock_pixmap_widget(StockPixmap icon) { GdkPixbuf *pixbuf; - cm_return_val_if_fail(icon >= 0 && icon < N_STOCK_PIXMAPS, NULL); + cm_return_val_if_fail(icon < N_STOCK_PIXMAPS, NULL); if (stock_pixbuf_gdk(icon, &pixbuf) != -1) return gtk_image_new_from_pixbuf(pixbuf); @@ -485,7 +485,7 @@ gint stock_pixbuf_gdk(StockPixmap icon, GdkPixbuf **pixbuf) if (pixbuf) *pixbuf = NULL; - cm_return_val_if_fail(icon >= 0 && icon < N_STOCK_PIXMAPS, -1); + cm_return_val_if_fail(icon < N_STOCK_PIXMAPS, -1); pix_d = &pixmaps[icon]; @@ -635,7 +635,7 @@ void stock_pixmap_themes_list_free(GList *list) gchar *stock_pixmap_get_name (StockPixmap icon) { - if (icon < 0 || icon >= N_STOCK_PIXMAPS) + if (icon >= N_STOCK_PIXMAPS) return NULL; return pixmaps[icon].file;