linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selinux: remove redundant assignment to str
@ 2017-10-14 12:46 Colin King
  2017-10-16 22:35 ` Paul Moore
  0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2017-10-14 12:46 UTC (permalink / raw)
  To: linux-security-module

From: Colin Ian King <colin.king@canonical.com>

str is being assigned to an empty string but str is never being
read after that, so the assignment is redundant and can be removed.
Moving the declaration of str to a more localised block, cleans up
clang warning: "Value stored to 'str' is never read"

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 security/selinux/hooks.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 07f35f3b4a13..3daf3369c3b4 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3177,18 +3177,17 @@ static int selinux_inode_setxattr(struct dentry *dentry, const char *name,
 		if (!has_cap_mac_admin(true)) {
 			struct audit_buffer *ab;
 			size_t audit_size;
-			const char *str;
 
 			/* We strip a nul only if it is at the end, otherwise the
 			 * context contains a nul and we should audit that */
 			if (value) {
-				str = value;
+				const char *str = value;
+
 				if (str[size - 1] == '\0')
 					audit_size = size - 1;
 				else
 					audit_size = size;
 			} else {
-				str = "";
 				audit_size = 0;
 			}
 			ab = audit_log_start(current->audit_context, GFP_ATOMIC, AUDIT_SELINUX_ERR);
-- 
2.14.1

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] selinux: remove redundant assignment to str
  2017-10-14 12:46 [PATCH] selinux: remove redundant assignment to str Colin King
@ 2017-10-16 22:35 ` Paul Moore
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Moore @ 2017-10-16 22:35 UTC (permalink / raw)
  To: linux-security-module

On Sat, Oct 14, 2017 at 8:46 AM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> str is being assigned to an empty string but str is never being
> read after that, so the assignment is redundant and can be removed.
> Moving the declaration of str to a more localised block, cleans up
> clang warning: "Value stored to 'str' is never read"
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  security/selinux/hooks.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)

Merged, thanks.

> diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
> index 07f35f3b4a13..3daf3369c3b4 100644
> --- a/security/selinux/hooks.c
> +++ b/security/selinux/hooks.c
> @@ -3177,18 +3177,17 @@ static int selinux_inode_setxattr(struct dentry *dentry, const char *name,
>                 if (!has_cap_mac_admin(true)) {
>                         struct audit_buffer *ab;
>                         size_t audit_size;
> -                       const char *str;
>
>                         /* We strip a nul only if it is at the end, otherwise the
>                          * context contains a nul and we should audit that */
>                         if (value) {
> -                               str = value;
> +                               const char *str = value;
> +
>                                 if (str[size - 1] == '\0')
>                                         audit_size = size - 1;
>                                 else
>                                         audit_size = size;
>                         } else {
> -                               str = "";
>                                 audit_size = 0;
>                         }
>                         ab = audit_log_start(current->audit_context, GFP_ATOMIC, AUDIT_SELINUX_ERR);
> --
> 2.14.1
>



-- 
paul moore
www.paul-moore.com
--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-10-16 22:35 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-10-14 12:46 [PATCH] selinux: remove redundant assignment to str Colin King
2017-10-16 22:35 ` Paul Moore

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).