]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
misc-utils: cleanup strtoxx_or_err()
authorKarel Zak <kzak@redhat.com>
Tue, 15 May 2012 15:44:37 +0000 (17:44 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 15 May 2012 15:44:37 +0000 (17:44 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
misc-utils/blkid.c
misc-utils/cal.c
misc-utils/findmnt.c
misc-utils/kill.c
misc-utils/logger.c
misc-utils/lslocks.c
misc-utils/wipefs.c

index 5268aba1e1f51a7db6bebbd9b2f20a48bec009c3..800784005fa77343c8e7687d5f73fbe2a7c8c329 100644 (file)
@@ -743,7 +743,7 @@ int main(int argc, char **argv)
                        }
                        break;
                case 'O':
-                       offset = strtosize_or_err(optarg, "failed to parse offset");
+                       offset = strtosize_or_err(optarg, "invalid offset argument");
                        break;
                case 'p':
                        lowprobe |= LOWPROBE_SUPERBLOCKS;
@@ -757,7 +757,7 @@ int main(int argc, char **argv)
                        show[numtag] = NULL;
                        break;
                case 'S':
-                       size = strtosize_or_err(optarg, "failed to parse size");
+                       size = strtosize_or_err(optarg, "invalid size argument");
                        break;
                case 't':
                        if (search_type) {
index 2de7164cd46f2fc7a4187af841093af63b0d02ad..60e85df0598692585bc5153654e5b33cab276acc 100644 (file)
@@ -368,17 +368,17 @@ main(int argc, char **argv) {
        day = month = year = 0;
        switch(argc) {
        case 3:
-               day = strtol_or_err(*argv++, _("illegal day value"));
+               day = strtos32_or_err(*argv++, _("illegal day value"));
                 if (day < 1 || 31 < day)
                        errx(EXIT_FAILURE, _("illegal day value: use 1-%d"), 31);
                /* FALLTHROUGH */
        case 2:
-               month = strtol_or_err(*argv++, _("illegal month value: use 1-12"));
+               month = strtos32_or_err(*argv++, _("illegal month value: use 1-12"));
                if (month < 1 || 12 < month)
                        errx(EXIT_FAILURE, _("illegal month value: use 1-12"));
                /* FALLTHROUGH */
        case 1:
-               year = strtol_or_err(*argv++, _("illegal year value: use 1-9999"));
+               year = strtos32_or_err(*argv++, _("illegal year value: use 1-9999"));
                if (year < 1 || 9999 < year)
                        errx(EXIT_FAILURE, _("illegal year value: use 1-9999"));
                if (day) {
index dc01d94adfcc761781565d5508c62c1578015575..1d34696c34ccf59a01e529820cfa39245a04526b 100644 (file)
@@ -1187,8 +1187,7 @@ int main(int argc, char *argv[])
                        flags |= FL_NOSWAPMATCH;
                        break;
                case 'w':
-                       timeout = strtol_or_err(optarg,
-                                       _("failed to parse timeout"));
+                       timeout = strtos32_or_err(optarg, _("invalid timeout argument"));
                        break;
                case 'V':
                        printf(UTIL_LINUX_VERSION);
index dc024924cb84f2c21489609af337425b05d7e5a8..da7c8abe68d94984ab9dc7306d3425abffdf624f 100644 (file)
@@ -245,7 +245,7 @@ int main (int argc, char *argv[])
            argc--, argv++;
            arg = *argv;
 #ifdef HAVE_SIGQUEUE
-           sigdata.sival_int = strtol_or_err(arg, _("failed to parse sigval"));
+           sigdata.sival_int = strtos32_or_err(arg, _("invalid sigval argument"));
            use_sigval = 1;
 #endif
            continue;
index e3b67d2a2029153aa84fb621a985a500d5ca1579..db3469c3d95ae02cb74e4b30327bc81307f11537 100644 (file)
@@ -63,7 +63,7 @@ int   decode __P((char *, CODE *));
 int    pencode __P((char *));
 
 static int optd = 0;
-static int udpport = 514;
+static uint16_t udpport = 514;
 
 static int
 myopenlog(const char *sock) {
@@ -86,7 +86,7 @@ myopenlog(const char *sock) {
 }
 
 static int
-udpopenlog(const char *servername,int port) {
+udpopenlog(const char *servername, uint16_t port) {
        int fd;
        struct sockaddr_in s_addr;
        struct hostent *serverhost;
@@ -169,7 +169,6 @@ main(int argc, char **argv) {
        char *usock = NULL;
        char *udpserver = NULL;
        int LogSock = -1;
-       long tmpport;
 
        static const struct option longopts[] = {
                { "id",         no_argument,        0, 'i' },
@@ -225,12 +224,8 @@ main(int argc, char **argv) {
                        udpserver = optarg;
                        break;
                case 'P':               /* change udp port */
-                       tmpport = strtol_or_err(optarg,
-                                               _("failed to parse port number"));
-                       if (tmpport < 0 || 65535 < tmpport)
-                               errx(EXIT_FAILURE, _("port `%ld' out of range"),
-                                               tmpport);
-                       udpport = (int) tmpport;
+                       udpport = strtou16_or_err(optarg,
+                                               _("invalid port number argument"));
                        break;
                case 'V':
                        printf(_("%s from %s\n"), program_invocation_short_name,
index 13eaaf332bda42feed75ea3ea36431f24755a76f..094224de68ae2056451dfa891a3f3ad78348d4a0 100644 (file)
@@ -268,7 +268,7 @@ static int get_local_locks(struct list_head *locks)
                                 * If user passed a pid we filter it later when adding
                                 * to the list, no need to worry now.
                                 */
-                               l->pid = strtol_or_err(tok, _("failed to parse pid"));
+                               l->pid = strtos32_or_err(tok, _("failed to parse pid"));
                                l->cmdname = get_cmdname(l->pid);
                                if (!l->cmdname)
                                        l->cmdname = xstrdup(_("(unknown)"));
@@ -280,14 +280,14 @@ static int get_local_locks(struct list_head *locks)
 
                        case 6: /* start */
                                l->start = !strcmp(tok, "EOF") ? 0 :
-                                          strtol_or_err(tok, _("failed to parse start"));
+                                          strtou64_or_err(tok, _("failed to parse start"));
                                break;
 
                        case 7: /* end */
                                /* replace '\n' character */
                                tok[strlen(tok)-1] = '\0';
                                l->end = !strcmp(tok, "EOF") ? 0 :
-                                        strtol_or_err(tok, _("failed to parse end"));
+                                        strtou64_or_err(tok, _("failed to parse end"));
                                break;
                        default:
                                break;
@@ -521,7 +521,7 @@ int main(int argc, char *argv[])
 
                switch(c) {
                case 'p':
-                       pid = strtol_or_err(optarg, _("cannot parse PID"));
+                       pid = strtos32_or_err(optarg, _("invalid PID argument"));
                        break;
                case 'o':
                        ncolumns = string_to_idarray(optarg,
index c751c3ac620d40ac314ed3074acd6fb8684a5517..e0ced2f6944b10ff9c726fc8c2a0258ced114895 100644 (file)
@@ -407,7 +407,7 @@ main(int argc, char **argv)
                        break;
                case 'o':
                        wp0 = add_offset(wp0, strtosize_or_err(optarg,
-                                        _("failed to parse offset")), 1);
+                                        _("invalid offset argument")), 1);
                        has_offset++;
                        break;
                case 'p':