Skip to contentSkip to conversation

AFS: Make the match_*() functions take const options

PATCH Applied David Howells 3 participants 6 messages May 1, 2007 – May 3, 2007

Subsystems (6)
lore
Share & tools
lore

David Howells

author maintainer
#0 lore raw

PATCH 1/2 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.

---

 include/linux/parser.h |    8 ++++----
 lib/parser.c           |   10 +++++-----
 2 files changed, 9 insertions(+), 9 deletions(-)
include/linux/parser.h +4 -4
index fa33328..86676f6 100644
@@ -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};
@@ -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 *);
lib/parser.c +5 -5
index 7ad2a48..703c8c1 100644
@@ -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;
@@ -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;
@@ -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++)
 		;
@@ -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';
@@ -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)
author maintainer
#1 lore raw

PATCH 2/2 AFS/AF_RXRPC: Miscellaneous fixes

Make miscellaneous fixes to AFS and AF_RXRPC:

(*) Make AF_RXRPC select KEYS rather than RXKAD or AFS_FS in Kconfig.

(*) Don't use FS_BINARY_MOUNTDATA.

(*) Remove a done 'TODO' item in a comemnt on afs_get_sb().

(*) Don't pass a void * as the page pointer argument of kmap_atomic() as this
breaks on m68k. Patch from Geert Uytterhoeven <[email protected]>.

(*) Use match_*() functions rather than doing my own parsing.

---

 fs/Kconfig        |    1 -
 fs/afs/fsclient.c |    3 +-
 fs/afs/super.c    |  100 +++++++++++++++++++++++------------------------------
 net/rxrpc/Kconfig |    3 +-
 4 files changed, 47 insertions(+), 60 deletions(-)
fs/Kconfig +0 -1
index a42f767..e33c089 100644
@@ -2020,7 +2020,6 @@ config AFS_FS
 	tristate "Andrew File System support (AFS) (EXPERIMENTAL)"
 	depends on INET && EXPERIMENTAL
 	select AF_RXRPC
-	select KEYS
 	help
 	  If you say Y here, you will get an experimental Andrew File System
 	  driver. It currently only supports unsecured read-only AFS access.
fs/afs/fsclient.c +2 -1
index 2393d2a..e54e6c2 100644
@@ -266,7 +266,8 @@ static int afs_deliver_fs_fetch_data(struct afs_call *call,
 		call->unmarshall++;
 
 		if (call->count < PAGE_SIZE) {
-			buffer = kmap_atomic(call->reply3, KM_USER0);
+			page = call->reply3;
+			buffer = kmap_atomic(page, KM_USER0);
 			memset(buffer + PAGE_SIZE - call->count, 0,
 			       call->count);
 			kunmap_atomic(buffer, KM_USER0);
fs/afs/super.c +43 -57

155 lines not on this page · raw message

net/rxrpc/Kconfig +2 -1
index 8750f6d..91b3d52 100644
@@ -5,6 +5,7 @@
 config AF_RXRPC
 	tristate "RxRPC session sockets"
 	depends on EXPERIMENTAL
+	select KEYS
 	help
 	  Say Y or M here to include support for RxRPC session sockets (just
 	  the transport part, not the presentation part: (un)marshalling is
@@ -29,7 +30,7 @@ config AF_RXRPC_DEBUG
 
 config RXKAD
 	tristate "RxRPC Kerberos security"
-	depends on AF_RXRPC && KEYS
+	depends on AF_RXRPC
 	select CRYPTO
 	select CRYPTO_MANAGER
 	select CRYPTO_BLKCIPHER
#2 lore raw

Re: [PATCH 2/2] AFS/AF_RXRPC: Miscellaneous fixes

Hi David,

I've just noticed another issue: if CONFIG_AFS_FS=y, the kernel build fails with

| afs_callback_update_kill' referenced in section .init.text' of fs/built-in.o: defined in discarded section .exit.text' of fs/built-in.o | afs_vlocation_purge' referenced in section .init.text' of fs/built-in.o: defined in discarded section .exit.text' of fs/built-in.o

and indeed, afs_init() calls both afs_callback_update_kill() and afs_vlocation_purge() in the failure path.

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

author maintainer
#3 lore raw

Re: [PATCH 2/2] AFS/AF_RXRPC: Miscellaneous fixes

Quoted 2 lines · Geert Uytterhoeven

I've just noticed another issue: if CONFIG_AFS_FS=y, the kernel build fails with

Can you send me the config you're using please?

David

maintainer Applied
#4 lore raw

Re: [PATCH 2/2] AFS/AF_RXRPC: Miscellaneous fixes

In reply to David Howells

From: David Howells <[email protected]>
Date: Tue, 01 May 2007 18:47:52 +0100

Quoted 6 lines

Make miscellaneous fixes to AFS and AF_RXRPC:

(*) Make AF_RXRPC select KEYS rather than RXKAD or AFS_FS in Kconfig.

(*) Don't use FS_BINARY_MOUNTDATA.

Quoted 8 lines

(*) Remove a done 'TODO' item in a comemnt on afs_get_sb().

(*) Don't pass a void * as the page pointer argument of kmap_atomic() as this
breaks on m68k. Patch from Geert Uytterhoeven <[email protected]>.

(*) Use match_*() functions rather than doing my own parsing.

Applied.