1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-21 23:58:49 -05:00

tests: fix -Wcast-qual warnings

Avoid casting string literals to non-const char *.
This commit is contained in:
Marcel Raad 2017-05-05 21:29:50 +02:00
parent 2b7bde4d3f
commit 6dc3422d48
No known key found for this signature in database
GPG Key ID: B4668817AE6D6CD4
6 changed files with 11 additions and 10 deletions

View File

@ -116,7 +116,7 @@ static void memory_tracking_init(void)
#endif #endif
/* returns a hexdump in a static memory area */ /* returns a hexdump in a static memory area */
char *hexdump(unsigned char *buffer, size_t len) char *hexdump(const unsigned char *buffer, size_t len)
{ {
static char dump[200*3+1]; static char dump[200*3+1];
char *p = dump; char *p = dump;

View File

@ -33,7 +33,7 @@ struct Tdata {
}; };
struct userdata { struct userdata {
char *text; const char *text;
int counter; int counter;
}; };
@ -184,7 +184,7 @@ int test(char *URL)
int i; int i;
struct userdata user; struct userdata user;
user.text = (char *)"Pigs in space"; user.text = "Pigs in space";
user.counter = 0; user.counter = 0;
printf("GLOBAL_INIT\n"); printf("GLOBAL_INIT\n");

View File

@ -31,7 +31,7 @@ struct Tdata {
}; };
struct userdata { struct userdata {
char *text; const char *text;
int counter; int counter;
}; };
@ -138,7 +138,7 @@ int test(char *URL)
int i; int i;
struct userdata user; struct userdata user;
user.text = (char *)"Pigs in space"; user.text = "Pigs in space";
user.counter = 0; user.counter = 0;
printf("GLOBAL_INIT\n"); printf("GLOBAL_INIT\n");

View File

@ -67,7 +67,7 @@ extern void wait_ms(int ms); /* wait this many milliseconds */
extern int test(char *URL); /* the actual test function provided by each extern int test(char *URL); /* the actual test function provided by each
individual libXXX.c file */ individual libXXX.c file */
extern char *hexdump(unsigned char *buffer, size_t len); extern char *hexdump(const unsigned char *buffer, size_t len);
#ifdef UNITTESTS #ifdef UNITTESTS
extern int unitfail; extern int unitfail;

View File

@ -39,9 +39,10 @@
#define verify_memory(dynamic, check, len) \ #define verify_memory(dynamic, check, len) \
if(dynamic && memcmp(dynamic, check, len)) { \ if(dynamic && memcmp(dynamic, check, len)) { \
fprintf(stderr, "%s:%d Memory buffer mismatch size %d. '%s' is not\n", \ fprintf(stderr, "%s:%d Memory buffer mismatch size %d. '%s' is not\n", \
__FILE__, __LINE__, len, hexdump((unsigned char *)check, len)); \ __FILE__, __LINE__, len, \
fprintf(stderr, "%s:%d the same as '%s'\n", \ hexdump((const unsigned char *)check, len)); \
__FILE__, __LINE__, hexdump((unsigned char *)dynamic, len)); \ fprintf(stderr, "%s:%d the same as '%s'\n", __FILE__, __LINE__, \
hexdump((const unsigned char *)dynamic, len)); \
unitfail++; \ unitfail++; \
} }

View File

@ -68,7 +68,7 @@ UNITTEST_START
}; };
for(i=0; i < sizeof(pairs)/sizeof(pairs[0]); i++) { for(i=0; i < sizeof(pairs)/sizeof(pairs[0]); i++) {
char *out = Curl_dedotdotify((char *)pairs[i].input); char *out = Curl_dedotdotify(pairs[i].input);
abort_unless(out != NULL, "returned NULL!"); abort_unless(out != NULL, "returned NULL!");
if(strcmp(out, pairs[i].output)) { if(strcmp(out, pairs[i].output)) {