hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/lib/kstrtox.c
....@@ -122,8 +122,7 @@
122122 * @res: Where to write the result of the conversion on success.
123123 *
124124 * 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.
127126 */
128127 int kstrtoull(const char *s, unsigned int base, unsigned long long *res)
129128 {
....@@ -146,8 +145,7 @@
146145 * @res: Where to write the result of the conversion on success.
147146 *
148147 * 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.
151149 */
152150 int kstrtoll(const char *s, unsigned int base, long long *res)
153151 {
....@@ -182,7 +180,7 @@
182180 rv = kstrtoull(s, base, &tmp);
183181 if (rv < 0)
184182 return rv;
185
- if (tmp != (unsigned long long)(unsigned long)tmp)
183
+ if (tmp != (unsigned long)tmp)
186184 return -ERANGE;
187185 *res = tmp;
188186 return 0;
....@@ -198,7 +196,7 @@
198196 rv = kstrtoll(s, base, &tmp);
199197 if (rv < 0)
200198 return rv;
201
- if (tmp != (long long)(long)tmp)
199
+ if (tmp != (long)tmp)
202200 return -ERANGE;
203201 *res = tmp;
204202 return 0;
....@@ -218,8 +216,7 @@
218216 * @res: Where to write the result of the conversion on success.
219217 *
220218 * 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.
223220 */
224221 int kstrtouint(const char *s, unsigned int base, unsigned int *res)
225222 {
....@@ -229,7 +226,7 @@
229226 rv = kstrtoull(s, base, &tmp);
230227 if (rv < 0)
231228 return rv;
232
- if (tmp != (unsigned long long)(unsigned int)tmp)
229
+ if (tmp != (unsigned int)tmp)
233230 return -ERANGE;
234231 *res = tmp;
235232 return 0;
....@@ -249,8 +246,7 @@
249246 * @res: Where to write the result of the conversion on success.
250247 *
251248 * 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.
254250 */
255251 int kstrtoint(const char *s, unsigned int base, int *res)
256252 {
....@@ -260,7 +256,7 @@
260256 rv = kstrtoll(s, base, &tmp);
261257 if (rv < 0)
262258 return rv;
263
- if (tmp != (long long)(int)tmp)
259
+ if (tmp != (int)tmp)
264260 return -ERANGE;
265261 *res = tmp;
266262 return 0;
....@@ -275,7 +271,7 @@
275271 rv = kstrtoull(s, base, &tmp);
276272 if (rv < 0)
277273 return rv;
278
- if (tmp != (unsigned long long)(u16)tmp)
274
+ if (tmp != (u16)tmp)
279275 return -ERANGE;
280276 *res = tmp;
281277 return 0;
....@@ -290,7 +286,7 @@
290286 rv = kstrtoll(s, base, &tmp);
291287 if (rv < 0)
292288 return rv;
293
- if (tmp != (long long)(s16)tmp)
289
+ if (tmp != (s16)tmp)
294290 return -ERANGE;
295291 *res = tmp;
296292 return 0;
....@@ -305,7 +301,7 @@
305301 rv = kstrtoull(s, base, &tmp);
306302 if (rv < 0)
307303 return rv;
308
- if (tmp != (unsigned long long)(u8)tmp)
304
+ if (tmp != (u8)tmp)
309305 return -ERANGE;
310306 *res = tmp;
311307 return 0;
....@@ -320,7 +316,7 @@
320316 rv = kstrtoll(s, base, &tmp);
321317 if (rv < 0)
322318 return rv;
323
- if (tmp != (long long)(s8)tmp)
319
+ if (tmp != (s8)tmp)
324320 return -ERANGE;
325321 *res = tmp;
326322 return 0;