Commit 135a9fcf45f8d41b4ab008114792f4f6c6572675

Authored by Andrew Morton
Committed by Linus Torvalds
1 parent f48fea035b

fs/adfs/adfs.h: fix unsigned comparison

fs/adfs/adfs.h: In function 'append_filetype_suffix':
fs/adfs/adfs.h:115: warning: comparison is always false due to limited range of data type

Reported-by: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Stuart Swales <stuart.swales.croftnuisk@gmail.com>
Cc: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 1 additions and 1 deletions Inline Diff

1 #include <linux/fs.h> 1 #include <linux/fs.h>
2 #include <linux/adfs_fs.h> 2 #include <linux/adfs_fs.h>
3 3
4 /* Internal data structures for ADFS */ 4 /* Internal data structures for ADFS */
5 5
6 #define ADFS_FREE_FRAG 0 6 #define ADFS_FREE_FRAG 0
7 #define ADFS_BAD_FRAG 1 7 #define ADFS_BAD_FRAG 1
8 #define ADFS_ROOT_FRAG 2 8 #define ADFS_ROOT_FRAG 2
9 9
10 #define ADFS_NDA_OWNER_READ (1 << 0) 10 #define ADFS_NDA_OWNER_READ (1 << 0)
11 #define ADFS_NDA_OWNER_WRITE (1 << 1) 11 #define ADFS_NDA_OWNER_WRITE (1 << 1)
12 #define ADFS_NDA_LOCKED (1 << 2) 12 #define ADFS_NDA_LOCKED (1 << 2)
13 #define ADFS_NDA_DIRECTORY (1 << 3) 13 #define ADFS_NDA_DIRECTORY (1 << 3)
14 #define ADFS_NDA_EXECUTE (1 << 4) 14 #define ADFS_NDA_EXECUTE (1 << 4)
15 #define ADFS_NDA_PUBLIC_READ (1 << 5) 15 #define ADFS_NDA_PUBLIC_READ (1 << 5)
16 #define ADFS_NDA_PUBLIC_WRITE (1 << 6) 16 #define ADFS_NDA_PUBLIC_WRITE (1 << 6)
17 17
18 #include "dir_f.h" 18 #include "dir_f.h"
19 19
20 struct buffer_head; 20 struct buffer_head;
21 21
22 /* 22 /*
23 * adfs file system inode data in memory 23 * adfs file system inode data in memory
24 */ 24 */
25 struct adfs_inode_info { 25 struct adfs_inode_info {
26 loff_t mmu_private; 26 loff_t mmu_private;
27 unsigned long parent_id; /* object id of parent */ 27 unsigned long parent_id; /* object id of parent */
28 __u32 loadaddr; /* RISC OS load address */ 28 __u32 loadaddr; /* RISC OS load address */
29 __u32 execaddr; /* RISC OS exec address */ 29 __u32 execaddr; /* RISC OS exec address */
30 unsigned int filetype; /* RISC OS file type */ 30 unsigned int filetype; /* RISC OS file type */
31 unsigned int attr; /* RISC OS permissions */ 31 unsigned int attr; /* RISC OS permissions */
32 unsigned int stamped:1; /* RISC OS file has date/time */ 32 unsigned int stamped:1; /* RISC OS file has date/time */
33 struct inode vfs_inode; 33 struct inode vfs_inode;
34 }; 34 };
35 35
36 /* 36 /*
37 * Forward-declare this 37 * Forward-declare this
38 */ 38 */
39 struct adfs_discmap; 39 struct adfs_discmap;
40 struct adfs_dir_ops; 40 struct adfs_dir_ops;
41 41
42 /* 42 /*
43 * ADFS file system superblock data in memory 43 * ADFS file system superblock data in memory
44 */ 44 */
45 struct adfs_sb_info { 45 struct adfs_sb_info {
46 struct adfs_discmap *s_map; /* bh list containing map */ 46 struct adfs_discmap *s_map; /* bh list containing map */
47 struct adfs_dir_ops *s_dir; /* directory operations */ 47 struct adfs_dir_ops *s_dir; /* directory operations */
48 48
49 uid_t s_uid; /* owner uid */ 49 uid_t s_uid; /* owner uid */
50 gid_t s_gid; /* owner gid */ 50 gid_t s_gid; /* owner gid */
51 umode_t s_owner_mask; /* ADFS owner perm -> unix perm */ 51 umode_t s_owner_mask; /* ADFS owner perm -> unix perm */
52 umode_t s_other_mask; /* ADFS other perm -> unix perm */ 52 umode_t s_other_mask; /* ADFS other perm -> unix perm */
53 int s_ftsuffix; /* ,xyz hex filetype suffix option */ 53 int s_ftsuffix; /* ,xyz hex filetype suffix option */
54 54
55 __u32 s_ids_per_zone; /* max. no ids in one zone */ 55 __u32 s_ids_per_zone; /* max. no ids in one zone */
56 __u32 s_idlen; /* length of ID in map */ 56 __u32 s_idlen; /* length of ID in map */
57 __u32 s_map_size; /* sector size of a map */ 57 __u32 s_map_size; /* sector size of a map */
58 unsigned long s_size; /* total size (in blocks) of this fs */ 58 unsigned long s_size; /* total size (in blocks) of this fs */
59 signed int s_map2blk; /* shift left by this for map->sector */ 59 signed int s_map2blk; /* shift left by this for map->sector */
60 unsigned int s_log2sharesize;/* log2 share size */ 60 unsigned int s_log2sharesize;/* log2 share size */
61 __le32 s_version; /* disc format version */ 61 __le32 s_version; /* disc format version */
62 unsigned int s_namelen; /* maximum number of characters in name */ 62 unsigned int s_namelen; /* maximum number of characters in name */
63 }; 63 };
64 64
65 static inline struct adfs_sb_info *ADFS_SB(struct super_block *sb) 65 static inline struct adfs_sb_info *ADFS_SB(struct super_block *sb)
66 { 66 {
67 return sb->s_fs_info; 67 return sb->s_fs_info;
68 } 68 }
69 69
70 static inline struct adfs_inode_info *ADFS_I(struct inode *inode) 70 static inline struct adfs_inode_info *ADFS_I(struct inode *inode)
71 { 71 {
72 return container_of(inode, struct adfs_inode_info, vfs_inode); 72 return container_of(inode, struct adfs_inode_info, vfs_inode);
73 } 73 }
74 74
75 /* 75 /*
76 * Directory handling 76 * Directory handling
77 */ 77 */
78 struct adfs_dir { 78 struct adfs_dir {
79 struct super_block *sb; 79 struct super_block *sb;
80 80
81 int nr_buffers; 81 int nr_buffers;
82 struct buffer_head *bh[4]; 82 struct buffer_head *bh[4];
83 83
84 /* big directories need allocated buffers */ 84 /* big directories need allocated buffers */
85 struct buffer_head **bh_fplus; 85 struct buffer_head **bh_fplus;
86 86
87 unsigned int pos; 87 unsigned int pos;
88 unsigned int parent_id; 88 unsigned int parent_id;
89 89
90 struct adfs_dirheader dirhead; 90 struct adfs_dirheader dirhead;
91 union adfs_dirtail dirtail; 91 union adfs_dirtail dirtail;
92 }; 92 };
93 93
94 /* 94 /*
95 * This is the overall maximum name length 95 * This is the overall maximum name length
96 */ 96 */
97 #define ADFS_MAX_NAME_LEN (256 + 4) /* +4 for ,xyz hex filetype suffix */ 97 #define ADFS_MAX_NAME_LEN (256 + 4) /* +4 for ,xyz hex filetype suffix */
98 struct object_info { 98 struct object_info {
99 __u32 parent_id; /* parent object id */ 99 __u32 parent_id; /* parent object id */
100 __u32 file_id; /* object id */ 100 __u32 file_id; /* object id */
101 __u32 loadaddr; /* load address */ 101 __u32 loadaddr; /* load address */
102 __u32 execaddr; /* execution address */ 102 __u32 execaddr; /* execution address */
103 __u32 size; /* size */ 103 __u32 size; /* size */
104 __u8 attr; /* RISC OS attributes */ 104 __u8 attr; /* RISC OS attributes */
105 unsigned int name_len; /* name length */ 105 unsigned int name_len; /* name length */
106 char name[ADFS_MAX_NAME_LEN];/* file name */ 106 char name[ADFS_MAX_NAME_LEN];/* file name */
107 107
108 /* RISC OS file type (12-bit: derived from loadaddr) */ 108 /* RISC OS file type (12-bit: derived from loadaddr) */
109 __u16 filetype; 109 __u16 filetype;
110 }; 110 };
111 111
112 /* RISC OS 12-bit filetype converts to ,xyz hex filename suffix */ 112 /* RISC OS 12-bit filetype converts to ,xyz hex filename suffix */
113 static inline int append_filetype_suffix(char *buf, __u16 filetype) 113 static inline int append_filetype_suffix(char *buf, __u16 filetype)
114 { 114 {
115 if (filetype == -1) 115 if (filetype == 0xffff) /* no explicit 12-bit file type was set */
116 return 0; 116 return 0;
117 117
118 *buf++ = ','; 118 *buf++ = ',';
119 *buf++ = hex_asc_lo(filetype >> 8); 119 *buf++ = hex_asc_lo(filetype >> 8);
120 *buf++ = hex_asc_lo(filetype >> 4); 120 *buf++ = hex_asc_lo(filetype >> 4);
121 *buf++ = hex_asc_lo(filetype >> 0); 121 *buf++ = hex_asc_lo(filetype >> 0);
122 return 4; 122 return 4;
123 } 123 }
124 124
125 struct adfs_dir_ops { 125 struct adfs_dir_ops {
126 int (*read)(struct super_block *sb, unsigned int id, unsigned int sz, struct adfs_dir *dir); 126 int (*read)(struct super_block *sb, unsigned int id, unsigned int sz, struct adfs_dir *dir);
127 int (*setpos)(struct adfs_dir *dir, unsigned int fpos); 127 int (*setpos)(struct adfs_dir *dir, unsigned int fpos);
128 int (*getnext)(struct adfs_dir *dir, struct object_info *obj); 128 int (*getnext)(struct adfs_dir *dir, struct object_info *obj);
129 int (*update)(struct adfs_dir *dir, struct object_info *obj); 129 int (*update)(struct adfs_dir *dir, struct object_info *obj);
130 int (*create)(struct adfs_dir *dir, struct object_info *obj); 130 int (*create)(struct adfs_dir *dir, struct object_info *obj);
131 int (*remove)(struct adfs_dir *dir, struct object_info *obj); 131 int (*remove)(struct adfs_dir *dir, struct object_info *obj);
132 int (*sync)(struct adfs_dir *dir); 132 int (*sync)(struct adfs_dir *dir);
133 void (*free)(struct adfs_dir *dir); 133 void (*free)(struct adfs_dir *dir);
134 }; 134 };
135 135
136 struct adfs_discmap { 136 struct adfs_discmap {
137 struct buffer_head *dm_bh; 137 struct buffer_head *dm_bh;
138 __u32 dm_startblk; 138 __u32 dm_startblk;
139 unsigned int dm_startbit; 139 unsigned int dm_startbit;
140 unsigned int dm_endbit; 140 unsigned int dm_endbit;
141 }; 141 };
142 142
143 /* Inode stuff */ 143 /* Inode stuff */
144 struct inode *adfs_iget(struct super_block *sb, struct object_info *obj); 144 struct inode *adfs_iget(struct super_block *sb, struct object_info *obj);
145 int adfs_write_inode(struct inode *inode, struct writeback_control *wbc); 145 int adfs_write_inode(struct inode *inode, struct writeback_control *wbc);
146 int adfs_notify_change(struct dentry *dentry, struct iattr *attr); 146 int adfs_notify_change(struct dentry *dentry, struct iattr *attr);
147 147
148 /* map.c */ 148 /* map.c */
149 extern int adfs_map_lookup(struct super_block *sb, unsigned int frag_id, unsigned int offset); 149 extern int adfs_map_lookup(struct super_block *sb, unsigned int frag_id, unsigned int offset);
150 extern unsigned int adfs_map_free(struct super_block *sb); 150 extern unsigned int adfs_map_free(struct super_block *sb);
151 151
152 /* Misc */ 152 /* Misc */
153 void __adfs_error(struct super_block *sb, const char *function, 153 void __adfs_error(struct super_block *sb, const char *function,
154 const char *fmt, ...); 154 const char *fmt, ...);
155 #define adfs_error(sb, fmt...) __adfs_error(sb, __func__, fmt) 155 #define adfs_error(sb, fmt...) __adfs_error(sb, __func__, fmt)
156 156
157 /* super.c */ 157 /* super.c */
158 158
159 /* 159 /*
160 * Inodes and file operations 160 * Inodes and file operations
161 */ 161 */
162 162
163 /* dir_*.c */ 163 /* dir_*.c */
164 extern const struct inode_operations adfs_dir_inode_operations; 164 extern const struct inode_operations adfs_dir_inode_operations;
165 extern const struct file_operations adfs_dir_operations; 165 extern const struct file_operations adfs_dir_operations;
166 extern const struct dentry_operations adfs_dentry_operations; 166 extern const struct dentry_operations adfs_dentry_operations;
167 extern struct adfs_dir_ops adfs_f_dir_ops; 167 extern struct adfs_dir_ops adfs_f_dir_ops;
168 extern struct adfs_dir_ops adfs_fplus_dir_ops; 168 extern struct adfs_dir_ops adfs_fplus_dir_ops;
169 169
170 extern int adfs_dir_update(struct super_block *sb, struct object_info *obj, 170 extern int adfs_dir_update(struct super_block *sb, struct object_info *obj,
171 int wait); 171 int wait);
172 172
173 /* file.c */ 173 /* file.c */
174 extern const struct inode_operations adfs_file_inode_operations; 174 extern const struct inode_operations adfs_file_inode_operations;
175 extern const struct file_operations adfs_file_operations; 175 extern const struct file_operations adfs_file_operations;
176 176
177 static inline __u32 signed_asl(__u32 val, signed int shift) 177 static inline __u32 signed_asl(__u32 val, signed int shift)
178 { 178 {
179 if (shift >= 0) 179 if (shift >= 0)
180 val <<= shift; 180 val <<= shift;
181 else 181 else
182 val >>= -shift; 182 val >>= -shift;
183 return val; 183 return val;
184 } 184 }
185 185
186 /* 186 /*
187 * Calculate the address of a block in an object given the block offset 187 * Calculate the address of a block in an object given the block offset
188 * and the object identity. 188 * and the object identity.
189 * 189 *
190 * The root directory ID should always be looked up in the map [3.4] 190 * The root directory ID should always be looked up in the map [3.4]
191 */ 191 */
192 static inline int 192 static inline int
193 __adfs_block_map(struct super_block *sb, unsigned int object_id, 193 __adfs_block_map(struct super_block *sb, unsigned int object_id,
194 unsigned int block) 194 unsigned int block)
195 { 195 {
196 if (object_id & 255) { 196 if (object_id & 255) {
197 unsigned int off; 197 unsigned int off;
198 198
199 off = (object_id & 255) - 1; 199 off = (object_id & 255) - 1;
200 block += off << ADFS_SB(sb)->s_log2sharesize; 200 block += off << ADFS_SB(sb)->s_log2sharesize;
201 } 201 }
202 202
203 return adfs_map_lookup(sb, object_id >> 8, block); 203 return adfs_map_lookup(sb, object_id >> 8, block);
204 } 204 }
205 205