diff options
author | Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it> | 2005-09-23 00:44:14 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-09-23 01:17:36 -0400 |
commit | a8bfb94c58238666df0d6856861d18f0f52fc752 (patch) | |
tree | ff22df262edafd55c9004a32a25dfb818c0841a9 /arch | |
parent | 3a02d6c051cf3c214aab38e4330b4bcec5f6e3f8 (diff) |
[PATCH] strlcat: use for uml umid.c
Simplify the code by using strlcat() instead of strncat() and manual
appending.
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Cc: Jeff Dike <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/um/include/user.h | 4 | ||||
-rw-r--r-- | arch/um/kernel/umid.c | 11 |
2 files changed, 7 insertions, 8 deletions
diff --git a/arch/um/include/user.h b/arch/um/include/user.h index 57ee9e261228..0f865ef46918 100644 --- a/arch/um/include/user.h +++ b/arch/um/include/user.h | |||
@@ -14,7 +14,9 @@ extern void *um_kmalloc_atomic(int size); | |||
14 | extern void kfree(void *ptr); | 14 | extern void kfree(void *ptr); |
15 | extern int in_aton(char *str); | 15 | extern int in_aton(char *str); |
16 | extern int open_gdb_chan(void); | 16 | extern int open_gdb_chan(void); |
17 | extern int strlcpy(char *, const char *, int); | 17 | /* These use size_t, however unsigned long is correct on both i386 and x86_64. */ |
18 | extern unsigned long strlcpy(char *, const char *, unsigned long); | ||
19 | extern unsigned long strlcat(char *, const char *, unsigned long); | ||
18 | extern void *um_vmalloc(int size); | 20 | extern void *um_vmalloc(int size); |
19 | extern void vfree(void *ptr); | 21 | extern void vfree(void *ptr); |
20 | 22 | ||
diff --git a/arch/um/kernel/umid.c b/arch/um/kernel/umid.c index 251d277fff2a..0b21d59ba0cd 100644 --- a/arch/um/kernel/umid.c +++ b/arch/um/kernel/umid.c | |||
@@ -237,16 +237,13 @@ static int __init make_uml_dir(void) | |||
237 | strlcpy(dir, home, sizeof(dir)); | 237 | strlcpy(dir, home, sizeof(dir)); |
238 | uml_dir++; | 238 | uml_dir++; |
239 | } | 239 | } |
240 | strlcat(dir, uml_dir, sizeof(dir)); | ||
240 | len = strlen(dir); | 241 | len = strlen(dir); |
241 | strncat(dir, uml_dir, sizeof(dir) - len); | 242 | if (len > 0 && dir[len - 1] != '/') |
242 | len = strlen(dir); | 243 | strlcat(dir, "/", sizeof(dir)); |
243 | if((len > 0) && (len < sizeof(dir) - 1) && (dir[len - 1] != '/')){ | ||
244 | dir[len] = '/'; | ||
245 | dir[len + 1] = '\0'; | ||
246 | } | ||
247 | 244 | ||
248 | uml_dir = malloc(strlen(dir) + 1); | 245 | uml_dir = malloc(strlen(dir) + 1); |
249 | if(uml_dir == NULL){ | 246 | if (uml_dir == NULL) { |
250 | printf("make_uml_dir : malloc failed, errno = %d\n", errno); | 247 | printf("make_uml_dir : malloc failed, errno = %d\n", errno); |
251 | exit(1); | 248 | exit(1); |
252 | } | 249 | } |