[Groonga-commit] groonga/groonga at 6736f19 [master] Suppress missing-field-initializers warnings

Back to archive index
Kouhei Sutou null+****@clear*****
Mon May 13 06:32:02 JST 2019


Kouhei Sutou	2019-05-13 06:32:02 +0900 (Mon, 13 May 2019)

  Revision: 6736f1989789a8b77181d09af9619d3f8bc3c01e
  https://github.com/groonga/groonga/commit/6736f1989789a8b77181d09af9619d3f8bc3c01e

  Message:
    Suppress missing-field-initializers warnings

  Modified files:
    CMakeLists.txt
    configure.ac
    lib/db.c
    lib/grn_db.h
    lib/ii.c
    lib/index_column.c
    lib/normalizer.c
    lib/tokenizer.c

  Modified: CMakeLists.txt (+1 -0)
===================================================================
--- CMakeLists.txt    2019-05-13 05:56:44 +0900 (855d61073)
+++ CMakeLists.txt    2019-05-13 06:32:02 +0900 (bd366ed68)
@@ -202,6 +202,7 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGCXX)
   # check_build_flag("-Wredundant-decls")
   check_build_flag("-Wwrite-strings")
   check_build_flag("-Wno-sign-compare")
+  check_build_flag("-Wmissing-field-initializers")
   check_cxxflag("-fexceptions")
   check_cxxflag("-fimplicit-templates")
 endif()

  Modified: configure.ac (+1 -0)
===================================================================
--- configure.ac    2019-05-13 05:56:44 +0900 (d735aaf0b)
+++ configure.ac    2019-05-13 06:32:02 +0900 (4683dfc06)
@@ -193,6 +193,7 @@ if test "$GCC" = "yes"; then
 #  CHECK_BUILD_FLAG([-Wconversion])
   CHECK_BUILD_FLAG([-Wwrite-strings])
 #  CHECK_BUILD_FLAG([-Winline])
+  CHECK_BUILD_FLAG([-Wmissing-field-initializers])
 
   CHECK_CXXFLAG([-fexceptions])
   CHECK_CXXFLAG([-fimplicit-templates])

  Modified: lib/db.c (+6 -3)
===================================================================
--- lib/db.c    2019-05-13 05:56:44 +0900 (516383756)
+++ lib/db.c    2019-05-13 06:32:02 +0900 (1df5b16cc)
@@ -1698,7 +1698,8 @@ grn_table_add(grn_ctx *ctx, grn_obj *table, const void *key, unsigned int key_si
       if (hooks) {
         // todo : grn_proc_ctx_open()
         grn_obj id_, flags_, oldvalue_, value_;
-        grn_proc_ctx pctx = {{0}, hooks->proc, NULL, hooks, hooks, PROC_INIT, 4, 4};
+        grn_proc_ctx pctx;
+        grn_proc_ctx_init(&pctx, hooks, 4, 4);
         GRN_UINT32_INIT(&id_, 0);
         GRN_UINT32_INIT(&flags_, 0);
         GRN_VOID_INIT(&oldvalue_);
@@ -2032,7 +2033,8 @@ call_delete_hook(grn_ctx *ctx, grn_obj *table, grn_id rid, const void *key, unsi
     if (hooks) {
       // todo : grn_proc_ctx_open()
       grn_obj id_, flags_, oldvalue_, value_;
-      grn_proc_ctx pctx = {{0}, hooks->proc, NULL, hooks, hooks, PROC_INIT, 4, 4};
+      grn_proc_ctx pctx;
+      grn_proc_ctx_init(&pctx, hooks, 4, 4);
       GRN_UINT32_INIT(&id_, 0);
       GRN_UINT32_INIT(&flags_, 0);
       GRN_TEXT_INIT(&oldvalue_, GRN_OBJ_DO_SHALLOW_COPY);
@@ -7453,7 +7455,8 @@ call_hook(grn_ctx *ctx, grn_obj *obj, grn_id id, grn_obj *value, int flags)
     if (hooks) {
       // todo : grn_proc_ctx_open()
       grn_obj id_, flags_;
-      grn_proc_ctx pctx = {{0}, hooks->proc, NULL, hooks, hooks, PROC_INIT, 4, 4};
+      grn_proc_ctx pctx;
+      grn_proc_ctx_init(&pctx, hooks, 4, 4);
       GRN_UINT32_INIT(&id_, 0);
       GRN_UINT32_INIT(&flags_, 0);
       GRN_UINT32_SET(ctx, &id_, id);

  Modified: lib/grn_db.h (+16 -1)
===================================================================
--- lib/grn_db.h    2019-05-13 05:56:44 +0900 (e2734f425)
+++ lib/grn_db.h    2019-05-13 06:32:02 +0900 (25229fe8a)
@@ -1,7 +1,7 @@
 /* -*- c-basic-offset: 2 -*- */
 /*
   Copyright(C) 2009-2018 Brazil
-  Copyright(C) 2018 Kouhei Sutou <kou****@clear*****>
+  Copyright(C) 2018-2019 Kouhei Sutou <kou****@clear*****>
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -253,6 +253,21 @@ struct _grn_proc_ctx {
   grn_user_data data[16];
 };
 
+static inline void
+grn_proc_ctx_init(grn_proc_ctx *pctx,
+                  grn_hook *hooks,
+                  unsigned short n_args,
+                  unsigned short offset)
+{
+  memset(pctx, 0, sizeof(*pctx));
+  pctx->proc = hooks->proc;
+  pctx->hooks = hooks;
+  pctx->currh = hooks;
+  pctx->phase = PROC_INIT;
+  pctx->nargs = n_args;
+  pctx->offset = offset;
+}
+
 struct _grn_proc {
   grn_db_obj obj;
   grn_obj name_buf;

  Modified: lib/ii.c (+12 -4)
===================================================================
--- lib/ii.c    2019-05-13 05:56:44 +0900 (d71620585)
+++ lib/ii.c    2019-05-13 06:32:02 +0900 (9f33b3435)
@@ -3615,7 +3615,10 @@ merger_get_next_buffer(grn_ctx *ctx, merger_data *data)
   } else {
     docinfo last_id = {
       buffer_data->id.rid,
-      buffer_data->id.sid
+      buffer_data->id.sid,
+      0,
+      0,
+      0
     };
     buffer_rec *record = BUFFER_REC_AT(buffer_data->buffer,
                                        buffer_data->next_position);
@@ -7913,9 +7916,13 @@ grn_ii_column_update(grn_ctx *ctx, grn_ii *ii, grn_id rid, unsigned int section,
     grn_ii_updspec *u_;
     uint32_t offset = 0;
     grn_id tid_ = 0, gap, tid, *tpe;
-    grn_table_sort_optarg arg = {GRN_TABLE_SORT_ASC|
-                                 GRN_TABLE_SORT_AS_NUMBER|
-                                 GRN_TABLE_SORT_AS_UNSIGNED, NULL, NULL,0 };
+    grn_table_sort_optarg arg = {
+      GRN_TABLE_SORT_ASC|GRN_TABLE_SORT_AS_NUMBER|GRN_TABLE_SORT_AS_UNSIGNED,
+      NULL,
+      NULL,
+      NULL,
+      0,
+    };
     grn_array *sorted = grn_array_create(ctx, NULL, sizeof(grn_id), 0);
     grn_hash_sort(ctx, (grn_hash *)new, -1, sorted, &arg);
     GRN_TEXT_PUT(ctx, posting, ((grn_hash *)new)->n_entries, sizeof(uint32_t));
@@ -9073,6 +9080,7 @@ grn_ii_similar_search(grn_ctx *ctx, grn_ii *ii,
       GRN_TABLE_SORT_DESC|GRN_TABLE_SORT_BY_VALUE|GRN_TABLE_SORT_AS_NUMBER,
       NULL,
       NULL,
+      NULL,
       0
     };
     grn_array *sorted = grn_array_create(ctx, NULL, sizeof(grn_id), 0);

  Modified: lib/index_column.c (+2 -1)
===================================================================
--- lib/index_column.c    2019-05-13 05:56:44 +0900 (7a47159b7)
+++ lib/index_column.c    2019-05-13 06:32:02 +0900 (b3f9ba9ae)
@@ -87,7 +87,8 @@ grn_index_column_build_call_hook(grn_ctx *ctx,
   if (hooks) {
     /* todo : grn_proc_ctx_open() */
     grn_obj id_, flags_;
-    grn_proc_ctx pctx = {{0}, hooks->proc, NULL, hooks, hooks, PROC_INIT, 4, 4};
+    grn_proc_ctx pctx;
+    grn_proc_ctx_init(&pctx, hooks, 4, 4);
     GRN_UINT32_INIT(&id_, 0);
     GRN_UINT32_INIT(&flags_, 0);
     GRN_UINT32_SET(ctx, &id_, id);

  Modified: lib/normalizer.c (+2 -3)
===================================================================
--- lib/normalizer.c    2019-05-13 05:56:44 +0900 (c2b43452e)
+++ lib/normalizer.c    2019-05-13 06:32:02 +0900 (d17bf74b2)
@@ -32,9 +32,8 @@ grn_normalizer_register(grn_ctx *ctx,
                         grn_proc_func *next,
                         grn_proc_func *fin)
 {
-  grn_expr_var vars[] = {
-    { NULL, 0 }
-  };
+  grn_expr_var vars[1];
+  memset(vars, 0, sizeof(vars));
   GRN_PTR_INIT(&vars[0].value, 0, GRN_ID_NIL);
 
   if (name_length < 0) {

  Modified: lib/tokenizer.c (+3 -6)
===================================================================
--- lib/tokenizer.c    2019-05-13 05:56:44 +0900 (e4198b9e3)
+++ lib/tokenizer.c    2019-05-13 06:32:02 +0900 (6e268c477)
@@ -1,7 +1,7 @@
 /* -*- c-basic-offset: 2 -*- */
 /*
   Copyright(C) 2012-2018 Brazil
-  Copyright(C) 2018 Kouhei Sutou <kou****@clear*****>
+  Copyright(C) 2018-2019 Kouhei Sutou <kou****@clear*****>
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -551,11 +551,8 @@ grn_tokenizer_register(grn_ctx *ctx, const char *plugin_name_ptr,
                        grn_proc_func *init, grn_proc_func *next,
                        grn_proc_func *fin)
 {
-  grn_expr_var vars[] = {
-    { NULL, 0 },
-    { NULL, 0 },
-    { NULL, 0 }
-  };
+  grn_expr_var vars[3];
+  memset(vars, 0, sizeof(vars));
   GRN_TEXT_INIT(&vars[0].value, 0);
   GRN_TEXT_INIT(&vars[1].value, 0);
   GRN_UINT32_INIT(&vars[2].value, 0);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190513/7bf44740/attachment-0001.html>


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