Author: ngie
Date: Sun Nov  5 22:36:32 2017
New Revision: 325462
URL: https://svnweb.freebsd.org/changeset/base/325462

Log:
  MFC r324928:
  
  Remove dead stores
  
  The return value of various snprintf calls was stored in `len` and not used
  in many functions.

Modified:
  stable/10/lib/libugidfw/ugidfw.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/lib/libugidfw/ugidfw.c
==============================================================================
--- stable/10/lib/libugidfw/ugidfw.c    Sun Nov  5 22:36:02 2017        
(r325461)
+++ stable/10/lib/libugidfw/ugidfw.c    Sun Nov  5 22:36:32 2017        
(r325462)
@@ -513,7 +513,6 @@ bsde_parse_uidrange(char *spec, uid_t *min, uid_t *max
        uid_t uid1, uid2;
        char *spec1, *spec2, *endp;
        unsigned long value;
-       size_t len;
 
        spec2 = spec;
        spec1 = strsep(&spec2, ":");
@@ -524,8 +523,7 @@ bsde_parse_uidrange(char *spec, uid_t *min, uid_t *max
        else {
                value = strtoul(spec1, &endp, 10);
                if (*endp != '\0') {
-                       len = snprintf(errstr, buflen,
-                           "invalid uid: '%s'", spec1);
+                       snprintf(errstr, buflen, "invalid uid: '%s'", spec1);
                        return (-1);
                }
                uid1 = value;
@@ -542,8 +540,7 @@ bsde_parse_uidrange(char *spec, uid_t *min, uid_t *max
        else {
                value = strtoul(spec2, &endp, 10);
                if (*endp != '\0') {
-                       len = snprintf(errstr, buflen,
-                           "invalid uid: '%s'", spec2);
+                       snprintf(errstr, buflen, "invalid uid: '%s'", spec2);
                        return (-1);
                }
                uid2 = value;
@@ -562,7 +559,6 @@ bsde_parse_gidrange(char *spec, gid_t *min, gid_t *max
        gid_t gid1, gid2;
        char *spec1, *spec2, *endp;
        unsigned long value;
-       size_t len;
 
        spec2 = spec;
        spec1 = strsep(&spec2, ":");
@@ -573,8 +569,7 @@ bsde_parse_gidrange(char *spec, gid_t *min, gid_t *max
        else {
                value = strtoul(spec1, &endp, 10);
                if (*endp != '\0') {
-                       len = snprintf(errstr, buflen,
-                           "invalid gid: '%s'", spec1);
+                       snprintf(errstr, buflen, "invalid gid: '%s'", spec1);
                        return (-1);
                }
                gid1 = value;
@@ -591,8 +586,7 @@ bsde_parse_gidrange(char *spec, gid_t *min, gid_t *max
        else {
                value = strtoul(spec2, &endp, 10);
                if (*endp != '\0') {
-                       len = snprintf(errstr, buflen,
-                           "invalid gid: '%s'", spec2);
+                       snprintf(errstr, buflen, "invalid gid: '%s'", spec2);
                        return (-1);
                }
                gid2 = value;
@@ -614,7 +608,6 @@ bsde_parse_subject(int argc, char *argv[],
        uid_t uid_min, uid_max;
        gid_t gid_min, gid_max;
        int jid;
-       size_t len;
        long value;
 
        current = 0;
@@ -631,11 +624,11 @@ bsde_parse_subject(int argc, char *argv[],
        while (current < argc) {
                if (strcmp(argv[current], "uid") == 0) {
                        if (current + 2 > argc) {
-                               len = snprintf(errstr, buflen, "uid short");
+                               snprintf(errstr, buflen, "uid short");
                                return (-1);
                        }
                        if (flags & MBS_UID_DEFINED) {
-                               len = snprintf(errstr, buflen, "one uid only");
+                               snprintf(errstr, buflen, "one uid only");
                                return (-1);
                        }
                        if (bsde_parse_uidrange(argv[current+1],
@@ -649,11 +642,11 @@ bsde_parse_subject(int argc, char *argv[],
                        current += 2;
                } else if (strcmp(argv[current], "gid") == 0) {
                        if (current + 2 > argc) {
-                               len = snprintf(errstr, buflen, "gid short");
+                               snprintf(errstr, buflen, "gid short");
                                return (-1);
                        }
                        if (flags & MBS_GID_DEFINED) {
-                               len = snprintf(errstr, buflen, "one gid only");
+                               snprintf(errstr, buflen, "one gid only");
                                return (-1);
                        }
                        if (bsde_parse_gidrange(argv[current+1],
@@ -667,17 +660,17 @@ bsde_parse_subject(int argc, char *argv[],
                        current += 2;
                } else if (strcmp(argv[current], "jailid") == 0) {
                        if (current + 2 > argc) {
-                               len = snprintf(errstr, buflen, "prison short");
+                               snprintf(errstr, buflen, "prison short");
                                return (-1);
                        }
                        if (flags & MBS_PRISON_DEFINED) {
-                               len = snprintf(errstr, buflen, "one jail only");
+                               snprintf(errstr, buflen, "one jail only");
                                return (-1);
                        }
                        value = strtol(argv[current+1], &endp, 10);
                        if (*endp != '\0') {
-                               len = snprintf(errstr, buflen,
-                                   "invalid jid: '%s'", argv[current+1]);
+                               snprintf(errstr, buflen, "invalid jid: '%s'",
+                                   argv[current+1]);
                                return (-1);
                        }
                        jid = value;
@@ -689,14 +682,13 @@ bsde_parse_subject(int argc, char *argv[],
                        current += 2;
                } else if (strcmp(argv[current], "!") == 0) {
                        if (nextnot) {
-                               len = snprintf(errstr, buflen,
-                                   "double negative");
+                               snprintf(errstr, buflen, "double negative");
                                return (-1);
                        }
                        nextnot = 1;
                        current += 1;
                } else {
-                       len = snprintf(errstr, buflen, "'%s' not expected",
+                       snprintf(errstr, buflen, "'%s' not expected",
                            argv[current]);
                        return (-1);
                }
@@ -724,7 +716,6 @@ bsde_parse_subject(int argc, char *argv[],
 int
 bsde_parse_type(char *spec, int *type, size_t buflen, char *errstr)
 {
-       size_t len;
        int i;
 
        *type = 0;
@@ -756,10 +747,10 @@ bsde_parse_type(char *spec, int *type, size_t buflen, 
                        *type |= MBO_ALL_TYPE;
                        break;
                default:
-                       len = snprintf(errstr, buflen, "Unknown type code: %c",
+                       snprintf(errstr, buflen, "Unknown type code: %c",
                            spec[i]);
                        return (-1);
-               } 
+               }
        }
 
        return (0);
@@ -768,11 +759,10 @@ bsde_parse_type(char *spec, int *type, size_t buflen, 
 int
 bsde_parse_fsid(char *spec, struct fsid *fsid, size_t buflen, char *errstr)
 {
-       size_t len;
        struct statfs buf;
 
        if (statfs(spec, &buf) < 0) {
-               len = snprintf(errstr, buflen, "Unable to get id for %s: %s",
+               snprintf(errstr, buflen, "Unable to get id for %s: %s",
                    spec, strerror(errno));
                return (-1);
        }
@@ -792,7 +782,6 @@ bsde_parse_object(int argc, char *argv[],
        gid_t gid_min, gid_max;
        int type;
        struct fsid fsid;
-       size_t len;
 
        current = 0;
        flags = 0;
@@ -808,11 +797,11 @@ bsde_parse_object(int argc, char *argv[],
        while (current < argc) {
                if (strcmp(argv[current], "uid") == 0) {
                        if (current + 2 > argc) {
-                               len = snprintf(errstr, buflen, "uid short");
+                               snprintf(errstr, buflen, "uid short");
                                return (-1);
                        }
                        if (flags & MBO_UID_DEFINED) {
-                               len = snprintf(errstr, buflen, "one uid only");
+                               snprintf(errstr, buflen, "one uid only");
                                return (-1);
                        }
                        if (bsde_parse_uidrange(argv[current+1],
@@ -826,11 +815,11 @@ bsde_parse_object(int argc, char *argv[],
                        current += 2;
                } else if (strcmp(argv[current], "gid") == 0) {
                        if (current + 2 > argc) {
-                               len = snprintf(errstr, buflen, "gid short");
+                               snprintf(errstr, buflen, "gid short");
                                return (-1);
                        }
                        if (flags & MBO_GID_DEFINED) {
-                               len = snprintf(errstr, buflen, "one gid only");
+                               snprintf(errstr, buflen, "one gid only");
                                return (-1);
                        }
                        if (bsde_parse_gidrange(argv[current+1],
@@ -844,11 +833,11 @@ bsde_parse_object(int argc, char *argv[],
                        current += 2;
                } else if (strcmp(argv[current], "filesys") == 0) {
                        if (current + 2 > argc) {
-                               len = snprintf(errstr, buflen, "filesys short");
+                               snprintf(errstr, buflen, "filesys short");
                                return (-1);
                        }
                        if (flags & MBO_FSID_DEFINED) {
-                               len = snprintf(errstr, buflen, "one fsid only");
+                               snprintf(errstr, buflen, "one fsid only");
                                return (-1);
                        }
                        if (bsde_parse_fsid(argv[current+1], &fsid,
@@ -890,11 +879,11 @@ bsde_parse_object(int argc, char *argv[],
                        current += 1;
                } else if (strcmp(argv[current], "type") == 0) {
                        if (current + 2 > argc) {
-                               len = snprintf(errstr, buflen, "type short");
+                               snprintf(errstr, buflen, "type short");
                                return (-1);
                        }
                        if (flags & MBO_TYPE_DEFINED) {
-                               len = snprintf(errstr, buflen, "one type only");
+                               snprintf(errstr, buflen, "one type only");
                                return (-1);
                        }
                        if (bsde_parse_type(argv[current+1], &type,
@@ -908,14 +897,14 @@ bsde_parse_object(int argc, char *argv[],
                        current += 2;
                } else if (strcmp(argv[current], "!") == 0) {
                        if (nextnot) {
-                               len = snprintf(errstr, buflen,
+                               snprintf(errstr, buflen,
                                    "double negative'");
                                return (-1);
                        }
                        nextnot = 1;
                        current += 1;
                } else {
-                       len = snprintf(errstr, buflen, "'%s' not expected",
+                       snprintf(errstr, buflen, "'%s' not expected",
                            argv[current]);
                        return (-1);
                }
@@ -946,16 +935,15 @@ int
 bsde_parse_mode(int argc, char *argv[], mode_t *mode, size_t buflen,
     char *errstr)
 {
-       size_t len;
        int i;
 
        if (argc == 0) {
-               len = snprintf(errstr, buflen, "mode expects mode value");
+               snprintf(errstr, buflen, "mode expects mode value");
                return (-1);
        }
 
        if (argc != 1) {
-               len = snprintf(errstr, buflen, "'%s' unexpected", argv[1]);
+               snprintf(errstr, buflen, "'%s' unexpected", argv[1]);
                return (-1);
        }
 
@@ -981,7 +969,7 @@ bsde_parse_mode(int argc, char *argv[], mode_t *mode, 
                        /* ignore */
                        break;
                default:
-                       len = snprintf(errstr, buflen, "Unknown mode letter: 
%c",
+                       snprintf(errstr, buflen, "Unknown mode letter: %c",
                            argv[0][i]);
                        return (-1);
                } 
@@ -998,17 +986,16 @@ bsde_parse_rule(int argc, char *argv[], struct mac_bsd
        int object, object_elements, object_elements_length;
        int mode, mode_elements, mode_elements_length;
        int error, i;
-       size_t len;
 
        bzero(rule, sizeof(*rule));
 
        if (argc < 1) {
-               len = snprintf(errstr, buflen, "Rule must begin with subject");
+               snprintf(errstr, buflen, "Rule must begin with subject");
                return (-1);
        }
 
        if (strcmp(argv[0], "subject") != 0) {
-               len = snprintf(errstr, buflen, "Rule must begin with subject");
+               snprintf(errstr, buflen, "Rule must begin with subject");
                return (-1);
        }
        subject = 0;
@@ -1022,7 +1009,7 @@ bsde_parse_rule(int argc, char *argv[], struct mac_bsd
                        object = i;
 
        if (object == -1) {
-               len = snprintf(errstr, buflen, "Rule must contain an object");
+               snprintf(errstr, buflen, "Rule must contain an object");
                return (-1);
        }
 
@@ -1033,7 +1020,7 @@ bsde_parse_rule(int argc, char *argv[], struct mac_bsd
                        mode = i;
 
        if (mode == -1) {
-               len = snprintf(errstr, buflen, "Rule must contain mode");
+               snprintf(errstr, buflen, "Rule must contain mode");
                return (-1);
        }
 
@@ -1112,12 +1099,12 @@ bsde_check_version(size_t buflen, char *errstr)
        len = sizeof(version);
        error = sysctlbyname(MIB ".rule_version", &version, &len, NULL, 0);
        if (error) {
-               len = snprintf(errstr, buflen, "version check failed: %s",
+               snprintf(errstr, buflen, "version check failed: %s",
                    strerror(errno));
                return (-1);
        }
        if (version != MB_VERSION) {
-               len = snprintf(errstr, buflen, "module v%d != library v%d",
+               snprintf(errstr, buflen, "module v%d != library v%d",
                    version, MB_VERSION);
                return (-1);
        }
@@ -1134,11 +1121,11 @@ bsde_get_rule_count(size_t buflen, char *errstr)
        len = sizeof(rule_count);
        error = sysctlbyname(MIB ".rule_count", &rule_count, &len, NULL, 0);
        if (error) {
-               len = snprintf(errstr, buflen, "%s", strerror(errno));
+               snprintf(errstr, buflen, "%s", strerror(errno));
                return (-1);
        }
        if (len != sizeof(rule_count)) {
-               len = snprintf(errstr, buflen, "Data error in %s.rule_count",
+               snprintf(errstr, buflen, "Data error in %s.rule_count",
                    MIB);
                return (-1);
        }
@@ -1156,12 +1143,11 @@ bsde_get_rule_slots(size_t buflen, char *errstr)
        len = sizeof(rule_slots);
        error = sysctlbyname(MIB ".rule_slots", &rule_slots, &len, NULL, 0);
        if (error) {
-               len = snprintf(errstr, buflen, "%s", strerror(errno));
+               snprintf(errstr, buflen, "%s", strerror(errno));
                return (-1);
        }
        if (len != sizeof(rule_slots)) {
-               len = snprintf(errstr, buflen, "Data error in %s.rule_slots",
-                   MIB);
+               snprintf(errstr, buflen, "Data error in %s.rule_slots", MIB);
                return (-1);
        }
 
@@ -1187,7 +1173,7 @@ bsde_get_rule(int rulenum, struct mac_bsdextended_rule
        len = 10;
        error = bsde_get_mib(MIB ".rules", name, &len);
        if (error) {
-               len = snprintf(errstr, errlen, "%s: %s", MIB ".rules",
+               snprintf(errstr, errlen, "%s: %s", MIB ".rules",
                    strerror(errno));
                return (-1);
        }
@@ -1199,11 +1185,11 @@ bsde_get_rule(int rulenum, struct mac_bsdextended_rule
        if (error  == -1 && errno == ENOENT)
                return (-2);
        if (error) {
-               len = snprintf(errstr, errlen, "%s.%d: %s", MIB ".rules",
+               snprintf(errstr, errlen, "%s.%d: %s", MIB ".rules",
                    rulenum, strerror(errno));
                return (-1);
        } else if (size != sizeof(*rule)) {
-               len = snprintf(errstr, errlen, "Data error in %s.%d: %s",
+               snprintf(errstr, errlen, "Data error in %s.%d: %s",
                    MIB ".rules", rulenum, strerror(errno));
                return (-1);
        }
@@ -1225,7 +1211,7 @@ bsde_delete_rule(int rulenum, size_t buflen, char *err
        len = 10;
        error = bsde_get_mib(MIB ".rules", name, &len);
        if (error) {
-               len = snprintf(errstr, buflen, "%s: %s", MIB ".rules",
+               snprintf(errstr, buflen, "%s: %s", MIB ".rules",
                    strerror(errno));
                return (-1);
        }
@@ -1236,7 +1222,7 @@ bsde_delete_rule(int rulenum, size_t buflen, char *err
        size = sizeof(rule);
        error = sysctl(name, len, NULL, NULL, &rule, 0);
        if (error) {
-               len = snprintf(errstr, buflen, "%s.%d: %s", MIB ".rules",
+               snprintf(errstr, buflen, "%s.%d: %s", MIB ".rules",
                    rulenum, strerror(errno));
                return (-1);
        }
@@ -1258,7 +1244,7 @@ bsde_set_rule(int rulenum, struct mac_bsdextended_rule
        len = 10;
        error = bsde_get_mib(MIB ".rules", name, &len);
        if (error) {
-               len = snprintf(errstr, buflen, "%s: %s", MIB ".rules",
+               snprintf(errstr, buflen, "%s: %s", MIB ".rules",
                    strerror(errno));
                return (-1);
        }
@@ -1269,7 +1255,7 @@ bsde_set_rule(int rulenum, struct mac_bsdextended_rule
        size = sizeof(*rule);
        error = sysctl(name, len, NULL, NULL, rule, size);
        if (error) {
-               len = snprintf(errstr, buflen, "%s.%d: %s", MIB ".rules",
+               snprintf(errstr, buflen, "%s.%d: %s", MIB ".rules",
                    rulenum, strerror(errno));
                return (-1);
        }
@@ -1292,14 +1278,14 @@ bsde_add_rule(int *rulenum, struct mac_bsdextended_rul
        len = 10;
        error = bsde_get_mib(MIB ".rules", name, &len);
        if (error) {
-               len = snprintf(errstr, buflen, "%s: %s", MIB ".rules",
+               snprintf(errstr, buflen, "%s: %s", MIB ".rules",
                    strerror(errno));
                return (-1);
        }
 
        rule_slots = bsde_get_rule_slots(BUFSIZ, charstr);
        if (rule_slots == -1) {
-               len = snprintf(errstr, buflen, "unable to get rule slots: %s",
+               snprintf(errstr, buflen, "unable to get rule slots: %s",
                    strerror(errno));
                return (-1);
        }
@@ -1310,7 +1296,7 @@ bsde_add_rule(int *rulenum, struct mac_bsdextended_rul
        size = sizeof(*rule);
        error = sysctl(name, len, NULL, NULL, rule, size);
        if (error) {
-               len = snprintf(errstr, buflen, "%s.%d: %s", MIB ".rules",
+               snprintf(errstr, buflen, "%s.%d: %s", MIB ".rules",
                    rule_slots, strerror(errno));
                return (-1);
        }
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to