[Groonga-commit] groonga/groonga at d1845f7 [master] clang: suppress a warning

Back to archive index

Kouhei Sutou null+****@clear*****
Tue Jun 11 17:21:00 JST 2013


Kouhei Sutou	2013-06-11 17:21:00 +0900 (Tue, 11 Jun 2013)

  New Revision: d1845f79a2ea337abb696093300e7fd392d71e22
  https://github.com/groonga/groonga/commit/d1845f79a2ea337abb696093300e7fd392d71e22

  Message:
    clang: suppress a warning
    
    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

  Modified files:
    lib/db.c

  Modified: lib/db.c (+1 -1)
===================================================================
--- lib/db.c    2013-06-11 17:17:20 +0900 (3eaaacf)
+++ lib/db.c    2013-06-11 17:21:00 +0900 (176d9a5)
@@ -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);
       });
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index