Browse code

Fix types around buffer_list_push(_data)

In C, strings are char pointers, not unsigned char pointers. And
arbitrary data is represented by a void pointer. Change buffer_list_push
and buffer_list_push_data to follow these rules, and remove any now
unneeded casts.

Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <1515573259-20968-1-git-send-email-steffan.karger@fox-it.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16186.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>

Steffan Karger authored on 2018/01/10 17:34:19
Showing 4 changed files
... ...
@@ -1169,7 +1169,7 @@ buffer_list_reset(struct buffer_list *ol)
1169 1169
 }
1170 1170
 
1171 1171
 void
1172
-buffer_list_push(struct buffer_list *ol, const unsigned char *str)
1172
+buffer_list_push(struct buffer_list *ol, const char *str)
1173 1173
 {
1174 1174
     if (str)
1175 1175
     {
... ...
@@ -1183,7 +1183,7 @@ buffer_list_push(struct buffer_list *ol, const unsigned char *str)
1183 1183
 }
1184 1184
 
1185 1185
 struct buffer_entry *
1186
-buffer_list_push_data(struct buffer_list *ol, const uint8_t *data, size_t size)
1186
+buffer_list_push_data(struct buffer_list *ol, const void *data, size_t size)
1187 1187
 {
1188 1188
     struct buffer_entry *e = NULL;
1189 1189
     if (data && (!ol->max_size || ol->size < ol->max_size))
... ...
@@ -1324,7 +1324,7 @@ buffer_list_file(const char *fn, int max_line_len)
1324 1324
             bl = buffer_list_new(0);
1325 1325
             while (fgets(line, max_line_len, fp) != NULL)
1326 1326
             {
1327
-                buffer_list_push(bl, (unsigned char *)line);
1327
+                buffer_list_push(bl, line);
1328 1328
             }
1329 1329
             free(line);
1330 1330
         }
... ...
@@ -1095,9 +1095,9 @@ bool buffer_list_defined(const struct buffer_list *ol);
1095 1095
 
1096 1096
 void buffer_list_reset(struct buffer_list *ol);
1097 1097
 
1098
-void buffer_list_push(struct buffer_list *ol, const unsigned char *str);
1098
+void buffer_list_push(struct buffer_list *ol, const char *str);
1099 1099
 
1100
-struct buffer_entry *buffer_list_push_data(struct buffer_list *ol, const uint8_t *data, size_t size);
1100
+struct buffer_entry *buffer_list_push_data(struct buffer_list *ol, const void *data, size_t size);
1101 1101
 
1102 1102
 struct buffer *buffer_list_peek(struct buffer_list *ol);
1103 1103
 
... ...
@@ -250,7 +250,7 @@ man_output_list_push_str(struct management *man, const char *str)
250 250
 {
251 251
     if (management_connected(man) && str)
252 252
     {
253
-        buffer_list_push(man->connection.out, (const unsigned char *) str);
253
+        buffer_list_push(man->connection.out, str);
254 254
     }
255 255
 }
256 256
 
... ...
@@ -2190,13 +2190,13 @@ man_read(struct management *man)
2190 2190
          * process command line if complete
2191 2191
          */
2192 2192
         {
2193
-            const unsigned char *line;
2193
+            const char *line;
2194 2194
             while ((line = command_line_get(man->connection.in)))
2195 2195
             {
2196 2196
 #ifdef MANAGEMENT_IN_EXTRA
2197 2197
                 if (man->connection.in_extra)
2198 2198
                 {
2199
-                    if (!strcmp((char *)line, "END"))
2199
+                    if (!strcmp(line, "END"))
2200 2200
                     {
2201 2201
                         in_extra_dispatch(man);
2202 2202
                     }
... ...
@@ -3791,18 +3791,18 @@ command_line_add(struct command_line *cl, const unsigned char *buf, const int le
3791 3791
     }
3792 3792
 }
3793 3793
 
3794
-const unsigned char *
3794
+const char *
3795 3795
 command_line_get(struct command_line *cl)
3796 3796
 {
3797 3797
     int i;
3798
-    const unsigned char *ret = NULL;
3798
+    const char *ret = NULL;
3799 3799
 
3800 3800
     i = buf_substring_len(&cl->buf, '\n');
3801 3801
     if (i >= 0)
3802 3802
     {
3803 3803
         buf_copy_excess(&cl->residual, &cl->buf, i);
3804 3804
         buf_chomp(&cl->buf);
3805
-        ret = (const unsigned char *) BSTR(&cl->buf);
3805
+        ret = BSTR(&cl->buf);
3806 3806
     }
3807 3807
     return ret;
3808 3808
 }
... ...
@@ -70,7 +70,7 @@ void command_line_free(struct command_line *cl);
70 70
 
71 71
 void command_line_add(struct command_line *cl, const unsigned char *buf, const int len);
72 72
 
73
-const unsigned char *command_line_get(struct command_line *cl);
73
+const char *command_line_get(struct command_line *cl);
74 74
 
75 75
 void command_line_reset(struct command_line *cl);
76 76