Skip to content

Commit

Permalink
[AFS]: Make the match_*() functions take const options.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
dhowells authored and davem330 committed May 3, 2007
1 parent 709525f commit ef4533f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions include/linux/parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
/* associates an integer enumerator with a pattern string. */
struct match_token {
int token;
char *pattern;
const char *pattern;
};

typedef struct match_token match_table_t[];
typedef const struct match_token match_table_t[];

/* Maximum number of arguments that match_token will find in a pattern */
enum {MAX_OPT_ARGS = 3};
Expand All @@ -29,5 +29,5 @@ int match_token(char *, match_table_t table, substring_t args[]);
int match_int(substring_t *, int *result);
int match_octal(substring_t *, int *result);
int match_hex(substring_t *, int *result);
void match_strcpy(char *, substring_t *);
char *match_strdup(substring_t *);
void match_strcpy(char *, const substring_t *);
char *match_strdup(const substring_t *);
10 changes: 5 additions & 5 deletions lib/parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* match extremely simple token=arg style patterns. If the pattern is found,
* the location(s) of the arguments will be returned in the @args array.
*/
static int match_one(char *s, char *p, substring_t args[])
static int match_one(char *s, const char *p, substring_t args[])
{
char *meta;
int argc = 0;
Expand All @@ -43,7 +43,7 @@ static int match_one(char *s, char *p, substring_t args[])
p = meta + 1;

if (isdigit(*p))
len = simple_strtoul(p, &p, 10);
len = simple_strtoul(p, (char **) &p, 10);
else if (*p == '%') {
if (*s++ != '%')
return 0;
Expand Down Expand Up @@ -102,7 +102,7 @@ static int match_one(char *s, char *p, substring_t args[])
*/
int match_token(char *s, match_table_t table, substring_t args[])
{
struct match_token *p;
const struct match_token *p;

for (p = table; !match_one(s, p->pattern, args) ; p++)
;
Expand Down Expand Up @@ -190,7 +190,7 @@ int match_hex(substring_t *s, int *result)
* &substring_t @s to the c-style string @to. Caller guarantees that @to is
* large enough to hold the characters of @s.
*/
void match_strcpy(char *to, substring_t *s)
void match_strcpy(char *to, const substring_t *s)
{
memcpy(to, s->from, s->to - s->from);
to[s->to - s->from] = '\0';
Expand All @@ -204,7 +204,7 @@ void match_strcpy(char *to, substring_t *s)
* the &substring_t @s. The caller is responsible for freeing the returned
* string with kfree().
*/
char *match_strdup(substring_t *s)
char *match_strdup(const substring_t *s)
{
char *p = kmalloc(s->to - s->from + 1, GFP_KERNEL);
if (p)
Expand Down

0 comments on commit ef4533f

Please sign in to comment.