| .. | .. |
|---|
| 122 | 122 | * @res: Where to write the result of the conversion on success. |
|---|
| 123 | 123 | * |
|---|
| 124 | 124 | * Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error. |
|---|
| 125 | | - * Used as a replacement for the obsolete simple_strtoull. Return code must |
|---|
| 126 | | - * be checked. |
|---|
| 125 | + * Preferred over simple_strtoull(). Return code must be checked. |
|---|
| 127 | 126 | */ |
|---|
| 128 | 127 | int kstrtoull(const char *s, unsigned int base, unsigned long long *res) |
|---|
| 129 | 128 | { |
|---|
| .. | .. |
|---|
| 146 | 145 | * @res: Where to write the result of the conversion on success. |
|---|
| 147 | 146 | * |
|---|
| 148 | 147 | * Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error. |
|---|
| 149 | | - * Used as a replacement for the obsolete simple_strtoull. Return code must |
|---|
| 150 | | - * be checked. |
|---|
| 148 | + * Preferred over simple_strtoll(). Return code must be checked. |
|---|
| 151 | 149 | */ |
|---|
| 152 | 150 | int kstrtoll(const char *s, unsigned int base, long long *res) |
|---|
| 153 | 151 | { |
|---|
| .. | .. |
|---|
| 182 | 180 | rv = kstrtoull(s, base, &tmp); |
|---|
| 183 | 181 | if (rv < 0) |
|---|
| 184 | 182 | return rv; |
|---|
| 185 | | - if (tmp != (unsigned long long)(unsigned long)tmp) |
|---|
| 183 | + if (tmp != (unsigned long)tmp) |
|---|
| 186 | 184 | return -ERANGE; |
|---|
| 187 | 185 | *res = tmp; |
|---|
| 188 | 186 | return 0; |
|---|
| .. | .. |
|---|
| 198 | 196 | rv = kstrtoll(s, base, &tmp); |
|---|
| 199 | 197 | if (rv < 0) |
|---|
| 200 | 198 | return rv; |
|---|
| 201 | | - if (tmp != (long long)(long)tmp) |
|---|
| 199 | + if (tmp != (long)tmp) |
|---|
| 202 | 200 | return -ERANGE; |
|---|
| 203 | 201 | *res = tmp; |
|---|
| 204 | 202 | return 0; |
|---|
| .. | .. |
|---|
| 218 | 216 | * @res: Where to write the result of the conversion on success. |
|---|
| 219 | 217 | * |
|---|
| 220 | 218 | * Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error. |
|---|
| 221 | | - * Used as a replacement for the obsolete simple_strtoull. Return code must |
|---|
| 222 | | - * be checked. |
|---|
| 219 | + * Preferred over simple_strtoul(). Return code must be checked. |
|---|
| 223 | 220 | */ |
|---|
| 224 | 221 | int kstrtouint(const char *s, unsigned int base, unsigned int *res) |
|---|
| 225 | 222 | { |
|---|
| .. | .. |
|---|
| 229 | 226 | rv = kstrtoull(s, base, &tmp); |
|---|
| 230 | 227 | if (rv < 0) |
|---|
| 231 | 228 | return rv; |
|---|
| 232 | | - if (tmp != (unsigned long long)(unsigned int)tmp) |
|---|
| 229 | + if (tmp != (unsigned int)tmp) |
|---|
| 233 | 230 | return -ERANGE; |
|---|
| 234 | 231 | *res = tmp; |
|---|
| 235 | 232 | return 0; |
|---|
| .. | .. |
|---|
| 249 | 246 | * @res: Where to write the result of the conversion on success. |
|---|
| 250 | 247 | * |
|---|
| 251 | 248 | * Returns 0 on success, -ERANGE on overflow and -EINVAL on parsing error. |
|---|
| 252 | | - * Used as a replacement for the obsolete simple_strtoull. Return code must |
|---|
| 253 | | - * be checked. |
|---|
| 249 | + * Preferred over simple_strtol(). Return code must be checked. |
|---|
| 254 | 250 | */ |
|---|
| 255 | 251 | int kstrtoint(const char *s, unsigned int base, int *res) |
|---|
| 256 | 252 | { |
|---|
| .. | .. |
|---|
| 260 | 256 | rv = kstrtoll(s, base, &tmp); |
|---|
| 261 | 257 | if (rv < 0) |
|---|
| 262 | 258 | return rv; |
|---|
| 263 | | - if (tmp != (long long)(int)tmp) |
|---|
| 259 | + if (tmp != (int)tmp) |
|---|
| 264 | 260 | return -ERANGE; |
|---|
| 265 | 261 | *res = tmp; |
|---|
| 266 | 262 | return 0; |
|---|
| .. | .. |
|---|
| 275 | 271 | rv = kstrtoull(s, base, &tmp); |
|---|
| 276 | 272 | if (rv < 0) |
|---|
| 277 | 273 | return rv; |
|---|
| 278 | | - if (tmp != (unsigned long long)(u16)tmp) |
|---|
| 274 | + if (tmp != (u16)tmp) |
|---|
| 279 | 275 | return -ERANGE; |
|---|
| 280 | 276 | *res = tmp; |
|---|
| 281 | 277 | return 0; |
|---|
| .. | .. |
|---|
| 290 | 286 | rv = kstrtoll(s, base, &tmp); |
|---|
| 291 | 287 | if (rv < 0) |
|---|
| 292 | 288 | return rv; |
|---|
| 293 | | - if (tmp != (long long)(s16)tmp) |
|---|
| 289 | + if (tmp != (s16)tmp) |
|---|
| 294 | 290 | return -ERANGE; |
|---|
| 295 | 291 | *res = tmp; |
|---|
| 296 | 292 | return 0; |
|---|
| .. | .. |
|---|
| 305 | 301 | rv = kstrtoull(s, base, &tmp); |
|---|
| 306 | 302 | if (rv < 0) |
|---|
| 307 | 303 | return rv; |
|---|
| 308 | | - if (tmp != (unsigned long long)(u8)tmp) |
|---|
| 304 | + if (tmp != (u8)tmp) |
|---|
| 309 | 305 | return -ERANGE; |
|---|
| 310 | 306 | *res = tmp; |
|---|
| 311 | 307 | return 0; |
|---|
| .. | .. |
|---|
| 320 | 316 | rv = kstrtoll(s, base, &tmp); |
|---|
| 321 | 317 | if (rv < 0) |
|---|
| 322 | 318 | return rv; |
|---|
| 323 | | - if (tmp != (long long)(s8)tmp) |
|---|
| 319 | + if (tmp != (s8)tmp) |
|---|
| 324 | 320 | return -ERANGE; |
|---|
| 325 | 321 | *res = tmp; |
|---|
| 326 | 322 | return 0; |
|---|