* [PATCH] selinux: Remove redundant assignment to rc
@ 2021-04-28 10:00 Jiapeng Chong
2021-05-11 1:49 ` Paul Moore
0 siblings, 1 reply; 2+ messages in thread
From: Jiapeng Chong @ 2021-04-28 10:00 UTC (permalink / raw)
To: paul; +Cc: stephen.smalley.work, eparis, selinux, linux-kernel, Jiapeng Chong
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>
---
security/selinux/ss/policydb.c | 1 -
security/selinux/ss/services.c | 4 ----
2 files changed, 5 deletions(-)
diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c
index 9fccf41..defc5ef 100644
--- a/security/selinux/ss/policydb.c
+++ b/security/selinux/ss/policydb.c
@@ -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]);
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c
index f0ba826..3331766 100644
--- a/security/selinux/ss/services.c
+++ b/security/selinux/ss/services.c
@@ -2059,7 +2059,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));
@@ -2068,7 +2067,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)
@@ -2076,7 +2074,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));
@@ -2100,7 +2097,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");
--
1.8.3.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] selinux: Remove redundant assignment to rc
2021-04-28 10:00 [PATCH] selinux: Remove redundant assignment to rc Jiapeng Chong
@ 2021-05-11 1:49 ` Paul Moore
0 siblings, 0 replies; 2+ messages in thread
From: Paul Moore @ 2021-05-11 1:49 UTC (permalink / raw)
To: Jiapeng Chong; +Cc: Stephen Smalley, Eric Paris, selinux, linux-kernel
On Wed, Apr 28, 2021 at 6:00 AM Jiapeng Chong
<jiapeng.chong@linux.alibaba.com> wrote:
>
> 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>
> ---
> security/selinux/ss/policydb.c | 1 -
> security/selinux/ss/services.c | 4 ----
> 2 files changed, 5 deletions(-)
Merged into selinux/next, thanks.
--
paul moore
www.paul-moore.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-05-11 1:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-28 10:00 [PATCH] selinux: Remove redundant assignment to rc Jiapeng Chong
2021-05-11 1:49 ` Paul Moore
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®