[Groonga-commit] groonga/groonga [master] enable write-strings warnings and suppress those warnings.

Back to archive index

null+****@clear***** null+****@clear*****
2012年 1月 10日 (火) 15:35:01 JST


Kouhei Sutou	2012-01-10 15:35:01 +0900 (Tue, 10 Jan 2012)

  New Revision: c01700cd68807294dc8eb772936d3835267702a2

  Log:
    enable write-strings warnings and suppress those warnings.
    
    Suggested by montywi. Thanks!!!

  Modified files:
    configure.ac
    include/groonga.h
    lib/ctx.c
    lib/ctx.h
    lib/expr.c
    lib/proc.c
    lib/scm.c
    lib/token.c
    src/grnslap.c
    src/grntest.c
    src/groonga.c

  Modified: configure.ac (+1 -1)
===================================================================
--- configure.ac    2012-01-10 14:41:24 +0900 (90d18d2)
+++ configure.ac    2012-01-10 15:35:01 +0900 (a8d67db)
@@ -138,7 +138,7 @@ if test "$GCC" = "yes"; then
 #  CHECK_CFLAG([-Wswitch-enum])
 #  CHECK_CFLAG([-Wshadow])
 #  CHECK_CFLAG([-Wconversion])
-#  CHECK_CFLAG([-Wwrite-strings])
+  CHECK_CFLAG([-Wwrite-strings])
 #  CHECK_CFLAG([-Winline])
 
   CHECK_CXXFLAG([-fexceptions])

  Modified: include/groonga.h (+3 -2)
===================================================================
--- include/groonga.h    2012-01-10 14:41:24 +0900 (ba3c6a7)
+++ include/groonga.h    2012-01-10 15:35:01 +0900 (f816a25)
@@ -1,4 +1,5 @@
-/* Copyright(C) 2009-2011 Brazil
+/*
+  Copyright(C) 2009-2012 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -624,7 +625,7 @@ GRN_API const char *grn_plugin_get_suffix(void);
  **/
 
 typedef struct {
-  char *name;
+  const char *name;
   unsigned name_size;
   grn_obj value;
 } grn_expr_var;

  Modified: lib/ctx.c (+3 -2)
===================================================================
--- lib/ctx.c    2012-01-10 14:41:24 +0900 (00278e6)
+++ lib/ctx.c    2012-01-10 15:35:01 +0900 (8f9cf8b)
@@ -1,5 +1,6 @@
 /* -*- c-basic-offset: 2 -*- */
-/* Copyright(C) 2009-2011 Brazil
+/*
+  Copyright(C) 2009-2012 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -2416,7 +2417,7 @@ grn_cell_clear(grn_ctx *ctx, grn_cell *o)
 /* don't handle error inside logger functions */
 
 void
-grn_ctx_log(grn_ctx *ctx, char *fmt, ...)
+grn_ctx_log(grn_ctx *ctx, const char *fmt, ...)
 {
   va_list argp;
   va_start(argp, fmt);

  Modified: lib/ctx.h (+3 -2)
===================================================================
--- lib/ctx.h    2012-01-10 14:41:24 +0900 (c8e6a0f)
+++ lib/ctx.h    2012-01-10 15:35:01 +0900 (b091ab3)
@@ -1,5 +1,6 @@
 /* -*- c-basic-offset: 2 -*- */
-/* Copyright(C) 2009 Brazil
+/*
+  Copyright(C) 2009-2012 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -423,7 +424,7 @@ GRN_API grn_rc grn_timeval_now(grn_ctx *ctx, grn_timeval *tv);
 GRN_API grn_rc grn_timeval2str(grn_ctx *ctx, grn_timeval *tv, char *buf);
 grn_rc grn_str2timeval(const char *str, uint32_t str_len, grn_timeval *tv);
 
-GRN_API void grn_ctx_log(grn_ctx *ctx, char *fmt, ...);
+GRN_API void grn_ctx_log(grn_ctx *ctx, const char *fmt, ...);
 void grn_ctx_qe_fin(grn_ctx *ctx);
 void grn_ctx_loader_clear(grn_ctx *ctx);
 void grn_log_reopen(grn_ctx *ctx);

  Modified: lib/expr.c (+3 -2)
===================================================================
--- lib/expr.c    2012-01-10 14:41:24 +0900 (b804052)
+++ lib/expr.c    2012-01-10 15:35:01 +0900 (8fe38be)
@@ -1,5 +1,6 @@
 /* -*- c-basic-offset: 2 -*- */
-/* Copyright(C) 2010 Brazil
+/*
+  Copyright(C) 2010-2012 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -142,7 +143,7 @@ grn_proc_alloc(grn_ctx *ctx, grn_user_data *user_data, grn_id domain, grn_obj_fl
 
 /* grn_expr */
 
-static char *opstrs[] = {
+static const char *opstrs[] = {
   "PUSH",
   "POP",
   "NOP",

  Modified: lib/proc.c (+5 -4)
===================================================================
--- lib/proc.c    2012-01-10 14:41:24 +0900 (68e15a9)
+++ lib/proc.c    2012-01-10 15:35:01 +0900 (cc0731e)
@@ -1,5 +1,6 @@
 /* -*- c-basic-offset: 2 -*- */
-/* Copyright(C) 2009-2011 Brazil
+/*
+  Copyright(C) 2009-2012 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -558,9 +559,9 @@ proc_select(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data)
   int limit = GRN_TEXT_LEN(VAR(8))
     ? grn_atoi(GRN_TEXT_VALUE(VAR(8)), GRN_BULK_CURR(VAR(8)), NULL)
     : DEFAULT_LIMIT;
-  char *output_columns = GRN_TEXT_VALUE(VAR(6));
+  const char *output_columns = GRN_TEXT_VALUE(VAR(6));
   uint32_t output_columns_len = GRN_TEXT_LEN(VAR(6));
-  char *drilldown_output_columns = GRN_TEXT_VALUE(VAR(11));
+  const char *drilldown_output_columns = GRN_TEXT_VALUE(VAR(11));
   uint32_t drilldown_output_columns_len = GRN_TEXT_LEN(VAR(11));
   int drilldown_offset = GRN_TEXT_LEN(VAR(12))
     ? grn_atoi(GRN_TEXT_VALUE(VAR(12)), GRN_BULK_CURR(VAR(12)), NULL)
@@ -1030,7 +1031,7 @@ print_columninfo(grn_ctx *ctx, grn_obj *column)
 {
   grn_obj o;
   grn_id id;
-  char *type;
+  const char *type;
   const char *path;
 
   switch (column->header.type) {

  Modified: lib/scm.c (+6 -5)
===================================================================
--- lib/scm.c    2012-01-10 14:41:24 +0900 (893671a)
+++ lib/scm.c    2012-01-10 15:35:01 +0900 (6154c26)
@@ -1,5 +1,6 @@
 /* -*- c-basic-offset: 2 -*- */
-/* Copyright(C) 2009 Brazil
+/*
+  Copyright(C) 2009-2012 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -687,7 +688,7 @@ grn_ql_mk_symbol2(grn_ctx *ctx, const char *q, unsigned int len, int kwdp)
 }
 
 static grn_cell *
-str2num(grn_ctx *ctx, char *str, unsigned int len)
+str2num(grn_ctx *ctx, const char *str, unsigned int len)
 {
   const char *cur, *str_end = str + len;
   int64_t i = grn_atoll(str, str_end, &cur);
@@ -1957,7 +1958,7 @@ opexe(grn_ctx *ctx)
           o->header.type = GRN_CELL_STR;
           o->header.impl_flags = 0;
           o->u.b.size = 1;
-          o->u.b.value = "?";
+          o->u.b.value = (char *)"?";
           *ctx->impl->pht = p;
           ctx->impl->pht = &CDR(p);
           s_return(ctx, o);
@@ -3332,7 +3333,7 @@ nf_geo_withinp(grn_ctx *ctx, grn_cell *args, grn_ql_co *co)
 /* ========== Initialization of internal keywords ========== */
 
 inline static void
-mk_syntax(grn_ctx *ctx, uint8_t op, char *name)
+mk_syntax(grn_ctx *ctx, uint8_t op, const char *name)
 {
   grn_cell *x;
   if ((x = INTERN(name)) != F) {
@@ -3342,7 +3343,7 @@ mk_syntax(grn_ctx *ctx, uint8_t op, char *name)
 }
 
 inline static void
-mk_proc(grn_ctx *ctx, uint8_t op, char *name)
+mk_proc(grn_ctx *ctx, uint8_t op, const char *name)
 {
   grn_cell *x;
   if ((x = INTERN(name)) != F) {

  Modified: lib/token.c (+8 -5)
===================================================================
--- lib/token.c    2012-01-10 14:41:24 +0900 (0491acb)
+++ lib/token.c    2012-01-10 15:35:01 +0900 (79d6647)
@@ -1,5 +1,6 @@
 /* -*- c-basic-offset: 2 -*- */
-/* Copyright(C) 2009-2011 Brazil
+/*
+  Copyright(C) 2009-2012 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -79,7 +80,7 @@ uvector_fin(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data)
 
 typedef struct {
   grn_str *nstr;
-  uint8_t *delimiter;
+  const uint8_t *delimiter;
   uint32_t delimiter_len;
   int32_t pos;
   grn_encoding encoding;
@@ -93,7 +94,7 @@ typedef struct {
 
 static grn_obj *
 delimited_init(grn_ctx *ctx, grn_obj *table, grn_user_data *user_data,
-               uint8_t *delimiter, uint32_t delimiter_len)
+               const uint8_t *delimiter, uint32_t delimiter_len)
 {
   grn_obj *str;
   int nflags = 0;
@@ -161,15 +162,17 @@ delimited_fin(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data)
 static grn_obj *
 delimit_init(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data)
 {
+  static const uint8_t delimiter[1] = {' '};
   grn_obj *table = args[0];
-  return delimited_init(ctx, table, user_data, " ", 1);
+  return delimited_init(ctx, table, user_data, delimiter, 1);
 }
 
 static grn_obj *
 delimit_null_init(grn_ctx *ctx, int nargs, grn_obj **args, grn_user_data *user_data)
 {
+  static const uint8_t delimiter[1] = {'\0'};
   grn_obj *table = args[0];
-  return delimited_init(ctx, table, user_data, "", 1);
+  return delimited_init(ctx, table, user_data, delimiter, 1);
 }
 
 /* ngram tokenizer */

  Modified: src/grnslap.c (+3 -2)
===================================================================
--- src/grnslap.c    2012-01-10 14:41:24 +0900 (4e98f76)
+++ src/grnslap.c    2012-01-10 15:35:01 +0900 (73e09f5)
@@ -1,5 +1,6 @@
 /* -*- c-basic-offset: 2 -*- */
-/* Copyright(C) 2009 Brazil
+/*
+  Copyright(C) 2009-2012 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -33,7 +34,7 @@
 #define MAX_DEST 256
 
 typedef struct {
-  char *host;
+  const char *host;
   uint16_t port;
 } grn_slap_dest;
 

  Modified: src/grntest.c (+14 -13)
===================================================================
--- src/grntest.c    2012-01-10 14:41:24 +0900 (9aa576d)
+++ src/grntest.c    2012-01-10 15:35:01 +0900 (2f7d2cf)
@@ -1,6 +1,6 @@
 /* -*- c-basic-offset: 2 -*- */
 /*
-  Copyright(C) 2010-2011 Brazil
+  Copyright(C) 2010-2012 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -102,7 +102,7 @@ static const char *groonga_path = "groonga";
 #endif /* WIN32 */
 
 static const char *groonga_protocol = "gqtp";
-static char *grntest_osinfo;
+static const char *grntest_osinfo;
 static int grntest_sigint = 0;
 
 
@@ -281,7 +281,7 @@ error_exit_in_thread(intptr_t code)
 
 
 static void
-escape_command(grn_ctx *ctx, char *in, int ilen, grn_obj *escaped_command)
+escape_command(grn_ctx *ctx, const char *in, int ilen, grn_obj *escaped_command)
 {
   int i = 0;
 
@@ -323,7 +323,7 @@ escape_command(grn_ctx *ctx, char *in, int ilen, grn_obj *escaped_command)
 }
 
 static int
-report_command(grn_ctx *ctx, char *command, char *ret, int task_id,
+report_command(grn_ctx *ctx, const char *command, const char *ret, int task_id,
                grn_obj *start_time, grn_obj *end_time)
 {
   int i, len, clen;
@@ -458,7 +458,7 @@ same_result_p(char *expect, int expected_length, char *result, int result_length
 }
 
 static socket_t
-open_socket(char *host, int port)
+open_socket(const char *host, int port)
 {
   socket_t sock;
   struct hostent *servhost;
@@ -492,7 +492,7 @@ open_socket(char *host, int port)
 }
 
 static int
-write_to_server(socket_t socket, char *buf)
+write_to_server(socket_t socket, const char *buf)
 {
 #ifdef DEBUG_FTP
   fprintf(stderr, "send:%s", buf);
@@ -505,7 +505,7 @@ write_to_server(socket_t socket, char *buf)
 #define OUTPUT_TYPE_LEN (sizeof(OUTPUT_TYPE) - 1)
 
 static void
-command_line_to_uri_path(grn_ctx *ctx, grn_obj *uri, char *command)
+command_line_to_uri_path(grn_ctx *ctx, grn_obj *uri, const char *command)
 {
   char tok_type;
   int offset = 0, have_key = 0;
@@ -588,7 +588,7 @@ command_line_to_uri_path(grn_ctx *ctx, grn_obj *uri, char *command)
 }
 
 static void
-command_send_http(grn_ctx *ctx, char *command, int type, int task_id)
+command_send_http(grn_ctx *ctx, const char *command, int type, int task_id)
 {
   socket_t http_socket;
   grn_obj buf;
@@ -634,7 +634,7 @@ command_send_http(grn_ctx *ctx, char *command, int type, int task_id)
 }
 
 static void
-command_send_ctx(grn_ctx *ctx, char *command, int type, int task_id)
+command_send_ctx(grn_ctx *ctx, const char *command, int type, int task_id)
 {
   grn_ctx_send(ctx, command, strlen(command), 0);
 /* fix me.
@@ -647,7 +647,7 @@ command_send_ctx(grn_ctx *ctx, char *command, int type, int task_id)
 }
 
 static void
-command_send(grn_ctx *ctx, char *command, int type, int task_id)
+command_send(grn_ctx *ctx, const char *command, int type, int task_id)
 {
   if (http_p(type)) {
     command_send_http(ctx, command, type, task_id);
@@ -2320,8 +2320,9 @@ get_size(char *buf)
 }
 
 int
-ftp_sub(char *user, char *passwd, char *host, const char *filename,
-         int mode, char *cd_dirname, char *retval)
+ftp_sub(const char *user, const char *passwd, const char *host,
+        const char *filename, int mode,
+        const char *cd_dirname, char *retval)
 {
   int size = 0;
   int status = 0;
@@ -2568,7 +2569,7 @@ get_date(char *date, time_t *sec)
 }
 
 static int
-get_scriptname(const char *path, char *name, char *suffix)
+get_scriptname(const char *path, char *name, const char *suffix)
 {
   int slen = strlen(suffix);
   int len = strlen(path);

  Modified: src/groonga.c (+3 -2)
===================================================================
--- src/groonga.c    2012-01-10 14:41:24 +0900 (c8e18ab)
+++ src/groonga.c    2012-01-10 15:35:01 +0900 (a9093f7)
@@ -1,5 +1,6 @@
 /* -*- c-basic-offset: 2 -*- */
-/* Copyright(C) 2009-2011 Brazil
+/*
+  Copyright(C) 2009-2012 Brazil
 
   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Lesser General Public
@@ -810,7 +811,7 @@ g_client(int argc, char **argv)
 {
   int rc = -1;
   grn_ctx ctx_, *ctx = &ctx_;
-  char *hostname = DEFAULT_DEST;
+  const char *hostname = DEFAULT_DEST;
   if (argc > 0 && argv) { hostname = *argv++; argc--; }
   grn_ctx_init(ctx, (batchmode ? GRN_CTX_BATCH_MODE : 0));
   if (!grn_ctx_connect(ctx, hostname, port, 0)) {




Groonga-commit メーリングリストの案内
Back to archive index