aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2007-05-03 06:10:39 -0400
committerDavid S. Miller <davem@davemloft.net>2007-05-03 06:10:39 -0400
commitef4533f8af7a8798cb8f52b06f47acf0c0d2d767 (patch)
tree446b3db739812391f0e476550b2e04161d126bff
parent709525fad8a925de16938caf7fce3bf601ef869c (diff)
[AFS]: Make the match_*() functions take const options.
Make the match_*() functions take a const pointer to the options table and make strings pointers in the options table const too. Signed-off-by: David Howells <dhowells@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/parser.h8
-rw-r--r--lib/parser.c10
2 files changed, 9 insertions, 9 deletions
diff --git a/include/linux/parser.h b/include/linux/parser.h
index fa3332861a09..86676f600992 100644
--- a/include/linux/parser.h
+++ b/include/linux/parser.h
@@ -11,10 +11,10 @@
11/* associates an integer enumerator with a pattern string. */ 11/* associates an integer enumerator with a pattern string. */
12struct match_token { 12struct match_token {
13 int token; 13 int token;
14 char *pattern; 14 const char *pattern;
15}; 15};
16 16
17typedef struct match_token match_table_t[]; 17typedef const struct match_token match_table_t[];
18 18
19/* Maximum number of arguments that match_token will find in a pattern */ 19/* Maximum number of arguments that match_token will find in a pattern */
20enum {MAX_OPT_ARGS = 3}; 20enum {MAX_OPT_ARGS = 3};
@@ -29,5 +29,5 @@ int match_token(char *, match_table_t table, substring_t args[]);
29int match_int(substring_t *, int *result); 29int match_int(substring_t *, int *result);
30int match_octal(substring_t *, int *result); 30int match_octal(substring_t *, int *result);
31int match_hex(substring_t *, int *result); 31int match_hex(substring_t *, int *result);
32void match_strcpy(char *, substring_t *); 32void match_strcpy(char *, const substring_t *);
33char *match_strdup(substring_t *); 33char *match_strdup(const substring_t *);
diff --git a/lib/parser.c b/lib/parser.c
index 7ad2a48abc5e..703c8c13b346 100644
--- a/lib/parser.c
+++ b/lib/parser.c
@@ -22,7 +22,7 @@
22 * match extremely simple token=arg style patterns. If the pattern is found, 22 * match extremely simple token=arg style patterns. If the pattern is found,
23 * the location(s) of the arguments will be returned in the @args array. 23 * the location(s) of the arguments will be returned in the @args array.
24 */ 24 */
25static int match_one(char *s, char *p, substring_t args[]) 25static int match_one(char *s, const char *p, substring_t args[])
26{ 26{
27 char *meta; 27 char *meta;
28 int argc = 0; 28 int argc = 0;
@@ -43,7 +43,7 @@ static int match_one(char *s, char *p, substring_t args[])
43 p = meta + 1; 43 p = meta + 1;
44 44
45 if (isdigit(*p)) 45 if (isdigit(*p))
46 len = simple_strtoul(p, &p, 10); 46 len = simple_strtoul(p, (char **) &p, 10);
47 else if (*p == '%') { 47 else if (*p == '%') {
48 if (*s++ != '%') 48 if (*s++ != '%')
49 return 0; 49 return 0;
@@ -102,7 +102,7 @@ static int match_one(char *s, char *p, substring_t args[])
102 */ 102 */
103int match_token(char *s, match_table_t table, substring_t args[]) 103int match_token(char *s, match_table_t table, substring_t args[])
104{ 104{
105 struct match_token *p; 105 const struct match_token *p;
106 106
107 for (p = table; !match_one(s, p->pattern, args) ; p++) 107 for (p = table; !match_one(s, p->pattern, args) ; p++)
108 ; 108 ;
@@ -190,7 +190,7 @@ int match_hex(substring_t *s, int *result)
190 * &substring_t @s to the c-style string @to. Caller guarantees that @to is 190 * &substring_t @s to the c-style string @to. Caller guarantees that @to is
191 * large enough to hold the characters of @s. 191 * large enough to hold the characters of @s.
192 */ 192 */
193void match_strcpy(char *to, substring_t *s) 193void match_strcpy(char *to, const substring_t *s)
194{ 194{
195 memcpy(to, s->from, s->to - s->from); 195 memcpy(to, s->from, s->to - s->from);
196 to[s->to - s->from] = '\0'; 196 to[s->to - s->from] = '\0';
@@ -204,7 +204,7 @@ void match_strcpy(char *to, substring_t *s)
204 * the &substring_t @s. The caller is responsible for freeing the returned 204 * the &substring_t @s. The caller is responsible for freeing the returned
205 * string with kfree(). 205 * string with kfree().
206 */ 206 */
207char *match_strdup(substring_t *s) 207char *match_strdup(const substring_t *s)
208{ 208{
209 char *p = kmalloc(s->to - s->from + 1, GFP_KERNEL); 209 char *p = kmalloc(s->to - s->from + 1, GFP_KERNEL);
210 if (p) 210 if (p)