From 0386a3e14b96c95b62064585f51417f09d750fbc Mon Sep 17 00:00:00 2001 From: Kalle Olavi Niemitalo Date: Sun, 18 Nov 2012 16:39:04 +0200 Subject: [PATCH] parse_header: make the 2nd parameter point to const In almost all calls to parse_header, the second argument is a string literal: parse_header(head, "Charset", NULL) for example. Of course, parse_header does not write to that string. Accordingly, make the parameter point to const, so calls that use a variable rather than a string literal can make that variable point to const too. Leaving the other parameters non-const for now. --- src/protocol/header.c | 5 +++-- src/protocol/header.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/protocol/header.c b/src/protocol/header.c index 80c47c0f8..8909c4bb7 100644 --- a/src/protocol/header.c +++ b/src/protocol/header.c @@ -116,14 +116,15 @@ #define LWS(c) ((c) == ' ' || (c) == ASCII_TAB) unsigned char * -parse_header(unsigned char *head, unsigned char *item, unsigned char **ptr) +parse_header(unsigned char *head, const unsigned char *item, unsigned char **ptr) { unsigned char *pos = head; if (!pos) return NULL; while (*pos) { - unsigned char *end, *itempos, *value; + unsigned char *end, *value; + const unsigned char *itempos; int len; /* Go for a newline. */ diff --git a/src/protocol/header.h b/src/protocol/header.h index 90b8fb23a..4643bfcb7 100644 --- a/src/protocol/header.h +++ b/src/protocol/header.h @@ -9,7 +9,7 @@ enum parse_header_param { * Unknown values should be treated as errors. */ }; -unsigned char *parse_header(unsigned char *, unsigned char *, unsigned char **); +unsigned char *parse_header(unsigned char *, const unsigned char *, unsigned char **); enum parse_header_param parse_header_param(unsigned char *, unsigned char *, unsigned char **); unsigned char *get_header_param(unsigned char *, unsigned char *);