Skip to content

Commit

Permalink
fix several -Wcast-qual warnings
Browse files Browse the repository at this point in the history
src/json.c:609:40: warning: cast from 'const char *' to 'char *' drops const qualifier [-Wcast-qual]
    escape_json_output (json, (char *) conf.filenames[idx]);
                                       ^
1 warning generated.

src/output.c:215:30: warning: cast from 'const char *' to 'char *' drops const qualifier [-Wcast-qual]
  clean_output (fp, (char *) title);
                             ^
1 warning generated.

src/sort.c:125:30: warning: cast from 'const void *' to 'char **' drops const qualifier [-Wcast-qual]
  return strcmp (*((char **) a), *((char **) b));
                             ^
src/sort.c:125:46: warning: cast from 'const void *' to 'char **' drops const qualifier [-Wcast-qual]
  return strcmp (*((char **) a), *((char **) b));
                                             ^
2 warnings generated.

src/util.c:925:25: warning: cast from 'const char *' to 'unsigned char *' drops const qualifier [-Wcast-qual]
  p = (unsigned char *) src;
                        ^
1 warning generated.

src/websocket.c:260:25: warning: cast from 'const char *' to 'unsigned char *' drops const qualifier [-Wcast-qual]
  p = (unsigned char *) src;
                        ^
src/websocket.c:1513:33: warning: cast from 'const char *' to 'unsigned char *' drops const qualifier [-Wcast-qual]
  SHA1Update (&sha, (uint8_t *) s, len);
                                ^
2 warnings generated.
  • Loading branch information
cgzones committed Nov 15, 2019
1 parent e656008 commit 1c910a9
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/json.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ fpjson (FILE * fp, const char *fmt, ...)

/* Escape all other characters accordingly. */
static void
escape_json_other (GJSON * json, char **s)
escape_json_other (GJSON * json, const char **s)
{
/* Since JSON data is bootstrapped into the HTML document of a report,
* then we perform the following four translations in case weird stuff
Expand Down Expand Up @@ -273,7 +273,7 @@ escape_json_other (GJSON * json, char **s)
*
* On success, escaped JSON data is outputted. */
static void
escape_json_output (GJSON * json, char *s)
escape_json_output (GJSON * json, const char *s)
{
while (*s) {
switch (*s) {
Expand Down Expand Up @@ -606,7 +606,7 @@ poverall_log_path (GJSON * json, int idx, int isp)
if (conf.filenames[idx][0] == '-' && conf.filenames[idx][1] == '\0')
pjson (json, "STDIN");
else
escape_json_output (json, (char *) conf.filenames[idx]);
escape_json_output (json, conf.filenames[idx]);
pjson (json, conf.filenames_idx - 1 != idx ? "\",\n" : "\"");
}

Expand Down
4 changes: 2 additions & 2 deletions src/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ panel_lookup (GModule module)

/* Sanitize output with html entities for special chars */
static void
clean_output (FILE * fp, char *s)
clean_output (FILE * fp, const char *s)
{
if (!s) {
LOG_DEBUG (("NULL data on clean_output.\n"));
Expand Down Expand Up @@ -212,7 +212,7 @@ print_html_title (FILE * fp)
conf.html_report_title ? conf.html_report_title : HTML_REPORT_TITLE;

fprintf (fp, "<title>");
clean_output (fp, (char *) title);
clean_output (fp, title);
fprintf (fp, "</title>");
}

Expand Down
2 changes: 1 addition & 1 deletion src/sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ GSort module_sort[TOTAL_MODULES] = {
int
strcmp_asc (const void *a, const void *b)
{
return strcmp (*((char **) a), *((char **) b));
return strcmp (*((char *const *) a), *((char * const*) b));
}

/* Sort 'data' metric ascending */
Expand Down
2 changes: 1 addition & 1 deletion src/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ escape_str (const char *src)
if (src == NULL || *src == '\0')
return NULL;

p = (unsigned char *) src;
p = (const unsigned char *) src;
q = dest = xmalloc (strlen (src) * 4 + 1);

while (*p) {
Expand Down
4 changes: 2 additions & 2 deletions src/websocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ escape_http_request (const char *src)
if (src == NULL || *src == '\0')
return NULL;

p = (unsigned char *) src;
p = (const unsigned char *) src;
q = dest = xmalloc (strlen (src) * 4 + 1);

while (*p) {
Expand Down Expand Up @@ -1505,7 +1505,7 @@ http_error (WSClient * client, const char *buffer)

/* Compute the SHA1 for the handshake. */
static void
ws_sha1_digest (const char *s, int len, unsigned char *digest)
ws_sha1_digest (char *s, int len, unsigned char *digest)
{
SHA1_CTX sha;

Expand Down

0 comments on commit 1c910a9

Please sign in to comment.