Commit 760dea671ea9c5b8c732d76d09673d6d052a186f
Committed by
Nathan Scott
1 parent
6f948fbd44
Exists in
master
and in
7 other branches
[XFS] Fix sparse warnings in kmem_* functions Patch from Victor Fusco
<victor@cetuc.puc-rio.br> SGI-PV: 940376 SGI-Modid: xfs-linux:xfs-kern:196705a Signed-off-by: Christoph Hellwig <hch@sgi.com> Signed-off-by: Nathan Scott <nathans@sgi.com>
Showing 3 changed files with 25 additions and 23 deletions Side-by-side Diff
fs/xfs/linux-2.6/kmem.c
... | ... | @@ -45,11 +45,11 @@ |
45 | 45 | |
46 | 46 | |
47 | 47 | void * |
48 | -kmem_alloc(size_t size, int flags) | |
48 | +kmem_alloc(size_t size, unsigned int __nocast flags) | |
49 | 49 | { |
50 | - int retries = 0; | |
51 | - int lflags = kmem_flags_convert(flags); | |
52 | - void *ptr; | |
50 | + int retries = 0; | |
51 | + unsigned int lflags = kmem_flags_convert(flags); | |
52 | + void *ptr; | |
53 | 53 | |
54 | 54 | do { |
55 | 55 | if (size < MAX_SLAB_SIZE || retries > MAX_VMALLOCS) |
... | ... | @@ -67,7 +67,7 @@ |
67 | 67 | } |
68 | 68 | |
69 | 69 | void * |
70 | -kmem_zalloc(size_t size, int flags) | |
70 | +kmem_zalloc(size_t size, unsigned int __nocast flags) | |
71 | 71 | { |
72 | 72 | void *ptr; |
73 | 73 | |
... | ... | @@ -89,7 +89,8 @@ |
89 | 89 | } |
90 | 90 | |
91 | 91 | void * |
92 | -kmem_realloc(void *ptr, size_t newsize, size_t oldsize, int flags) | |
92 | +kmem_realloc(void *ptr, size_t newsize, size_t oldsize, | |
93 | + unsigned int __nocast flags) | |
93 | 94 | { |
94 | 95 | void *new; |
95 | 96 | |
96 | 97 | |
... | ... | @@ -104,11 +105,11 @@ |
104 | 105 | } |
105 | 106 | |
106 | 107 | void * |
107 | -kmem_zone_alloc(kmem_zone_t *zone, int flags) | |
108 | +kmem_zone_alloc(kmem_zone_t *zone, unsigned int __nocast flags) | |
108 | 109 | { |
109 | - int retries = 0; | |
110 | - int lflags = kmem_flags_convert(flags); | |
111 | - void *ptr; | |
110 | + int retries = 0; | |
111 | + unsigned int lflags = kmem_flags_convert(flags); | |
112 | + void *ptr; | |
112 | 113 | |
113 | 114 | do { |
114 | 115 | ptr = kmem_cache_alloc(zone, lflags); |
... | ... | @@ -123,7 +124,7 @@ |
123 | 124 | } |
124 | 125 | |
125 | 126 | void * |
126 | -kmem_zone_zalloc(kmem_zone_t *zone, int flags) | |
127 | +kmem_zone_zalloc(kmem_zone_t *zone, unsigned int __nocast flags) | |
127 | 128 | { |
128 | 129 | void *ptr; |
129 | 130 |
fs/xfs/linux-2.6/kmem.h
... | ... | @@ -39,10 +39,10 @@ |
39 | 39 | /* |
40 | 40 | * memory management routines |
41 | 41 | */ |
42 | -#define KM_SLEEP 0x0001 | |
43 | -#define KM_NOSLEEP 0x0002 | |
44 | -#define KM_NOFS 0x0004 | |
45 | -#define KM_MAYFAIL 0x0008 | |
42 | +#define KM_SLEEP 0x0001u | |
43 | +#define KM_NOSLEEP 0x0002u | |
44 | +#define KM_NOFS 0x0004u | |
45 | +#define KM_MAYFAIL 0x0008u | |
46 | 46 | |
47 | 47 | #define kmem_zone kmem_cache_s |
48 | 48 | #define kmem_zone_t kmem_cache_t |
49 | 49 | |
... | ... | @@ -81,9 +81,9 @@ |
81 | 81 | *(NSTATEP) = *(OSTATEP); \ |
82 | 82 | } while (0) |
83 | 83 | |
84 | -static __inline unsigned int kmem_flags_convert(int flags) | |
84 | +static __inline unsigned int kmem_flags_convert(unsigned int __nocast flags) | |
85 | 85 | { |
86 | - int lflags = __GFP_NOWARN; /* we'll report problems, if need be */ | |
86 | + unsigned int lflags = __GFP_NOWARN; /* we'll report problems, if need be */ | |
87 | 87 | |
88 | 88 | #ifdef DEBUG |
89 | 89 | if (unlikely(flags & ~(KM_SLEEP|KM_NOSLEEP|KM_NOFS|KM_MAYFAIL))) { |
90 | 90 | |
... | ... | @@ -125,12 +125,13 @@ |
125 | 125 | BUG(); |
126 | 126 | } |
127 | 127 | |
128 | -extern void *kmem_zone_zalloc(kmem_zone_t *, int); | |
129 | -extern void *kmem_zone_alloc(kmem_zone_t *, int); | |
128 | +extern void *kmem_zone_zalloc(kmem_zone_t *, unsigned int __nocast); | |
129 | +extern void *kmem_zone_alloc(kmem_zone_t *, unsigned int __nocast); | |
130 | 130 | |
131 | -extern void *kmem_alloc(size_t, int); | |
132 | -extern void *kmem_realloc(void *, size_t, size_t, int); | |
133 | -extern void *kmem_zalloc(size_t, int); | |
131 | +extern void *kmem_alloc(size_t, unsigned int __nocast); | |
132 | +extern void *kmem_realloc(void *, size_t, size_t, | |
133 | + unsigned int __nocast); | |
134 | +extern void *kmem_zalloc(size_t, unsigned int __nocast); | |
134 | 135 | extern void kmem_free(void *, size_t); |
135 | 136 | |
136 | 137 | typedef struct shrinker *kmem_shaker_t; |
fs/xfs/xfs_log_recover.c
... | ... | @@ -1387,7 +1387,7 @@ |
1387 | 1387 | old_ptr = item->ri_buf[item->ri_cnt-1].i_addr; |
1388 | 1388 | old_len = item->ri_buf[item->ri_cnt-1].i_len; |
1389 | 1389 | |
1390 | - ptr = kmem_realloc(old_ptr, len+old_len, old_len, 0); | |
1390 | + ptr = kmem_realloc(old_ptr, len+old_len, old_len, 0u); | |
1391 | 1391 | memcpy(&ptr[old_len], dp, len); /* d, s, l */ |
1392 | 1392 | item->ri_buf[item->ri_cnt-1].i_len += len; |
1393 | 1393 | item->ri_buf[item->ri_cnt-1].i_addr = ptr; |