Sfoglia il codice sorgente

ncd: fix clang warnings

ambrop7 13 anni fa
parent
commit
885b2e739a
6 ha cambiato i file con 14 aggiunte e 14 eliminazioni
  1. 2 2
      ncd/NCDValue.c
  2. 2 2
      ncd/NCDValueParser.c
  3. 1 1
      ncd/modules/file.c
  4. 3 3
      ncd/modules/implode.c
  5. 5 5
      ncd/modules/regex_match.c
  6. 1 1
      ncd/ncd.c

+ 2 - 2
ncd/NCDValue.c

@@ -241,7 +241,7 @@ int NCDValue_StringEquals (NCDValue *o, const char *str)
 {
     ASSERT(o->type == NCDVALUE_STRING)
     
-    return NCDValue_StringHasNoNulls(o) && !strcmp(o->string, str);
+    return NCDValue_StringHasNoNulls(o) && !strcmp((const char *)o->string, str);
 }
 
 int NCDValue_IsList (NCDValue *o)
@@ -607,7 +607,7 @@ NCDValue * NCDValue_MapFindValueByString (NCDValue *o, const char *key_str)
     
     NCDValue key;
     key.type = NCDVALUE_STRING;
-    key.string = (char *)key_str;
+    key.string = (uint8_t *)key_str;
     key.string_len = strlen(key_str);
     
     NCDValue *ekey = NCDValue_MapFindKey(o, &key);

+ 2 - 2
ncd/NCDValueParser.c

@@ -148,7 +148,7 @@ static int build_value (struct NCDConfig_list *ast, NCDValue *out)
 {
     switch (ast->type) {
         case NCDCONFIG_ARG_STRING: {
-            if (!NCDValue_InitStringBin(out, ast->string, ast->string_len)) {
+            if (!NCDValue_InitStringBin(out, (uint8_t *)ast->string, ast->string_len)) {
                 BLog(BLOG_ERROR, "NCDValue_InitStringBin failed");
                 return 0;
             }
@@ -276,7 +276,7 @@ int NCDValueParser_Parse (const char *str, size_t str_len, NCDValue *out_value)
     NCDValue val;
     switch (state.out.ast_type) {
         case AST_TYPE_STRING: {
-            if (!NCDValue_InitStringBin(&val, state.out.ast_string.str, state.out.ast_string.len)) {
+            if (!NCDValue_InitStringBin(&val, (uint8_t *)state.out.ast_string.str, state.out.ast_string.len)) {
                 BLog(BLOG_ERROR, "NCDValue_InitStringBin failed");
                 goto out;
             }

+ 1 - 1
ncd/modules/file.c

@@ -161,7 +161,7 @@ static void write_func_new (NCDModuleInst *i)
     }
     
     // write file
-    if (!write_file(NCDValue_StringValue(filename_arg), NCDValue_StringValue(contents_arg), NCDValue_StringLength(contents_arg))) {
+    if (!write_file(NCDValue_StringValue(filename_arg), (const uint8_t *)NCDValue_StringValue(contents_arg), NCDValue_StringLength(contents_arg))) {
         ModuleLog(i, BLOG_ERROR, "failed to write file");
         goto fail0;
     }

+ 3 - 3
ncd/modules/implode.c

@@ -91,14 +91,14 @@ static void func_new (NCDModuleInst *i)
         
         // append glue
         if (piece != NCDValue_ListFirst(pieces_arg)) {
-            if (!ExpString_AppendBinary(&str, NCDValue_StringValue(glue_arg), NCDValue_StringLength(glue_arg))) {
+            if (!ExpString_AppendBinary(&str, (const uint8_t *)NCDValue_StringValue(glue_arg), NCDValue_StringLength(glue_arg))) {
                 ModuleLog(i, BLOG_ERROR, "ExpString_AppendBinary failed");
                 goto fail2;
             }
         }
         
         // append piece
-        if (!ExpString_AppendBinary(&str, NCDValue_StringValue(piece), NCDValue_StringLength(piece))) {
+        if (!ExpString_AppendBinary(&str, (const uint8_t *)NCDValue_StringValue(piece), NCDValue_StringLength(piece))) {
             ModuleLog(i, BLOG_ERROR, "ExpString_AppendBinary failed");
             goto fail2;
         }
@@ -140,7 +140,7 @@ static int func_getvar (void *vo, const char *name, NCDValue *out_value)
     struct instance *o = vo;
     
     if (!strcmp(name, "")) {
-        if (!NCDValue_InitStringBin(out_value, o->result, o->result_len)) {
+        if (!NCDValue_InitStringBin(out_value, (uint8_t *)o->result, o->result_len)) {
             ModuleLog(o->i, BLOG_ERROR, "NCDValue_InitStringBin failed");
             return 0;
         }

+ 5 - 5
ncd/modules/regex_match.c

@@ -133,13 +133,13 @@ static int regex_replace (const char *input, size_t input_len, const char *regex
         ASSERT(matches[0].rm_eo <= input_len)
         
         // append data before match
-        if (!ExpString_AppendBinary(&str, input, matches[0].rm_so)) {
+        if (!ExpString_AppendBinary(&str, (const uint8_t *)input, matches[0].rm_so)) {
             ModuleLog(i, BLOG_ERROR, "ExpString_AppendBinary failed");
             goto fail2;
         }
         
         // append replace data
-        if (!ExpString_AppendBinary(&str, replace, replace_len)) {
+        if (!ExpString_AppendBinary(&str, (const uint8_t *)replace, replace_len)) {
             ModuleLog(i, BLOG_ERROR, "ExpString_AppendBinary failed");
             goto fail2;
         }
@@ -150,7 +150,7 @@ static int regex_replace (const char *input, size_t input_len, const char *regex
     }
     
     // append remaining data
-    if (!ExpString_AppendBinary(&str, input, input_len)) {
+    if (!ExpString_AppendBinary(&str, (const uint8_t *)input, input_len)) {
         ModuleLog(i, BLOG_ERROR, "ExpString_AppendBinary failed");
         goto fail2;
     }
@@ -268,7 +268,7 @@ static int func_getvar (void *vo, const char *name, NCDValue *out)
             
             size_t len = m->rm_eo - m->rm_so;
             
-            if (!NCDValue_InitStringBin(out, o->input + m->rm_so, len)) {
+            if (!NCDValue_InitStringBin(out, (uint8_t *)o->input + m->rm_so, len)) {
                 ModuleLog(o->i, BLOG_ERROR, "NCDValue_InitStringBin failed");
                 return 0;
             }
@@ -385,7 +385,7 @@ static int replace_func_getvar (void *vo, const char *name, NCDValue *out)
     struct replace_instance *o = vo;
     
     if (!strcmp(name, "")) {
-        if (!NCDValue_InitStringBin(out, o->output, o->output_len)) {
+        if (!NCDValue_InitStringBin(out, (uint8_t *)o->output, o->output_len)) {
             ModuleLog(o->i, BLOG_ERROR, "NCDValue_InitStringBin failed");
             return 0;
         }

+ 1 - 1
ncd/ncd.c

@@ -1539,7 +1539,7 @@ int process_statement_resolve_argument (struct process_statement *ps, struct arg
     
     switch (arg->type) {
         case ARG_VALUE_TYPE_STRING: {
-            if (!NCDValue_InitStringBin(out, arg->string, arg->string_len)) {
+            if (!NCDValue_InitStringBin(out, (uint8_t *)arg->string, arg->string_len)) {
                 process_statement_log(ps, BLOG_ERROR, "NCDValue_InitStringBin failed");
                 return 0;
             }