log_logstash plugin: Fix non-portable struct initialization with "{}".
[collectd.git] / src / log_logstash.c
index 3ef7139..6ebab3b 100644 (file)
@@ -79,7 +79,6 @@ static void log_logstash_print(yajl_gen g, int severity,
   struct tm timestamp_tm;
   char timestamp_str[64];
   const unsigned char *buf;
-  time_t tt;
 #if HAVE_YAJL_V2
   size_t len;
 #else
@@ -127,8 +126,7 @@ static void log_logstash_print(yajl_gen g, int severity,
       yajl_gen_status_ok)
     goto err;
 
-  tt = CDTIME_T_TO_TIME_T(timestamp_time);
-  gmtime_r(&tt, &timestamp_tm);
+  gmtime_r(&CDTIME_T_TO_TIME_T(timestamp_time), &timestamp_tm);
 
   /*
    * format time as a UTC ISO 8601 compliant string
@@ -185,22 +183,14 @@ err:
 
 static void log_logstash_log(int severity, const char *msg,
                              user_data_t __attribute__((unused)) * user_data) {
-  yajl_gen g;
-#if !defined(HAVE_YAJL_V2)
-  yajl_gen_config conf = {};
-
-  conf.beautify = 0;
-#endif
-
   if (severity > log_level)
     return;
 
 #if HAVE_YAJL_V2
-  g = yajl_gen_alloc(NULL);
+  yajl_gen g = yajl_gen_alloc(NULL);
 #else
-  g = yajl_gen_alloc(&conf, NULL);
+  yajl_gen g = yajl_gen_alloc(&(yajl_gen_config){0}, NULL);
 #endif
-
   if (g == NULL) {
     fprintf(stderr, "Could not allocate JSON generator.\n");
     return;