]> granicus.if.org Git - neomutt/commitdiff
tidy: mutt_str_atos()
authorRichard Russon <rich@flatcap.org>
Mon, 22 Apr 2019 23:05:49 +0000 (00:05 +0100)
committerRichard Russon <rich@flatcap.org>
Wed, 24 Apr 2019 19:28:10 +0000 (20:28 +0100)
mutt/string.c

index 56054008feebfb0220bb35a794a3cbcafc3707b9..69a6336dbf75ce67993d87aa8f991356815b1b50 100644 (file)
@@ -232,20 +232,19 @@ int mutt_str_atol(const char *str, long *dst)
  */
 int mutt_str_atos(const char *str, short *dst)
 {
-  int rc;
-  long res;
-  short tmp;
-  short *t = dst ? dst : &tmp;
-
-  *t = 0;
+  if (dst)
+    *dst = 0;
 
-  rc = mutt_str_atol(str, &res);
+  long res = 0;
+  int rc = mutt_str_atol(str, &res);
   if (rc < 0)
     return rc;
-  if ((short) res != res)
+  if ((res < SHRT_MIN) || (res > SHRT_MAX))
     return -2;
 
-  *t = (short) res;
+  if (dst)
+    *dst = (short) res;
+
   return 0;
 }