selinux: Remove redundant assignment to rc
authorJiapeng Chong <jiapeng.chong@linux.alibaba.com>
Wed, 28 Apr 2021 10:00:15 +0000 (18:00 +0800)
committerPaul Moore <paul@paul-moore.com>
Tue, 11 May 2021 01:48:11 +0000 (21:48 -0400)
Variable rc is set to '-EINVAL' but this value is never read as
it is overwritten or not used later on, hence it is a redundant
assignment and can be removed.

Cleans up the following clang-analyzer warning:

security/selinux/ss/services.c:2103:3: warning: Value stored to 'rc' is
never read [clang-analyzer-deadcode.DeadStores].

security/selinux/ss/services.c:2079:2: warning: Value stored to 'rc' is
never read [clang-analyzer-deadcode.DeadStores].

security/selinux/ss/services.c:2071:2: warning: Value stored to 'rc' is
never read [clang-analyzer-deadcode.DeadStores].

security/selinux/ss/services.c:2062:2: warning: Value stored to 'rc' is
never read [clang-analyzer-deadcode.DeadStores].

security/selinux/ss/policydb.c:2592:3: warning: Value stored to 'rc' is
never read [clang-analyzer-deadcode.DeadStores].

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
security/selinux/ss/policydb.c
security/selinux/ss/services.c

index 9fccf417006b06cf9b209a5df2ac815811e03bc7..defc5ef35c665b59e3f9f7936f33c632edc85c45 100644 (file)
@@ -2589,7 +2589,6 @@ int policydb_read(struct policydb *p, void *fp)
                if (rc)
                        goto bad;
 
-               rc = -EINVAL;
                rtk->role = le32_to_cpu(buf[0]);
                rtk->type = le32_to_cpu(buf[1]);
                rtd->new_role = le32_to_cpu(buf[2]);
index 0a5ce001609b37a772915122c5d4779eec974d1c..3658488efdcba5300ece32454f0e165eebcb15a3 100644 (file)
@@ -2060,7 +2060,6 @@ static int convert_context(struct context *oldc, struct context *newc, void *p)
        context_init(newc);
 
        /* Convert the user. */
-       rc = -EINVAL;
        usrdatum = symtab_search(&args->newp->p_users,
                                 sym_name(args->oldp,
                                          SYM_USERS, oldc->user - 1));
@@ -2069,7 +2068,6 @@ static int convert_context(struct context *oldc, struct context *newc, void *p)
        newc->user = usrdatum->value;
 
        /* Convert the role. */
-       rc = -EINVAL;
        role = symtab_search(&args->newp->p_roles,
                             sym_name(args->oldp, SYM_ROLES, oldc->role - 1));
        if (!role)
@@ -2077,7 +2075,6 @@ static int convert_context(struct context *oldc, struct context *newc, void *p)
        newc->role = role->value;
 
        /* Convert the type. */
-       rc = -EINVAL;
        typdatum = symtab_search(&args->newp->p_types,
                                 sym_name(args->oldp,
                                          SYM_TYPES, oldc->type - 1));
@@ -2101,7 +2098,6 @@ static int convert_context(struct context *oldc, struct context *newc, void *p)
                oc = args->newp->ocontexts[OCON_ISID];
                while (oc && oc->sid[0] != SECINITSID_UNLABELED)
                        oc = oc->next;
-               rc = -EINVAL;
                if (!oc) {
                        pr_err("SELinux:  unable to look up"
                                " the initial SIDs list\n");