Navigation Menu

Skip to content

Commit

Permalink
clang: suppress a warning
Browse files Browse the repository at this point in the history
Initialize grn_id explicitly.

    db.c:2430:7: warning: variable 'id' is used uninitialized whenever 'if'
          condition is false [-Wsometimes-uninitialized]
          WITH_NORMALIZE(hash, key, key_size, {
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    db.c:46:9: note: expanded from macro 'WITH_NORMALIZE'
        if ((nstr = grn_string_open(ctx, key, key_size,\
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    db.c:2433:11: note: uninitialized use occurs here
          if (id) { grn_table_add(ctx, res, &id, sizeof(grn_id), NULL); }
              ^~
    db.c:2430:7: note: remove the 'if' if its condition is always true
          WITH_NORMALIZE(hash, key, key_size, {
          ^
    db.c:46:5: note: expanded from macro 'WITH_NORMALIZE'
        if ((nstr = grn_string_open(ctx, key, key_size,\
        ^
    db.c:2429:16: note: initialize the variable 'id' to silence this warning
          grn_id id;
                   ^
                    = 0
  • Loading branch information
kou committed Jun 11, 2013
1 parent 31cd5fc commit d1845f7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/db.c
Expand Up @@ -2426,7 +2426,7 @@ grn_table_search(grn_ctx *ctx, grn_obj *table, const void *key, uint32_t key_siz
case GRN_TABLE_HASH_KEY :
{
grn_hash *hash = (grn_hash *)table;
grn_id id;
grn_id id = GRN_ID_NIL;
WITH_NORMALIZE(hash, key, key_size, {
id = grn_hash_get(ctx, hash, key, key_size, NULL);
});
Expand Down

0 comments on commit d1845f7

Please sign in to comment.