Re: [PATCH 2/3] kernel/audit: audit_string_contains_control can be boolean

From: Paul Moore
Date: Tue Sep 29 2015 - 14:38:04 EST


On Tuesday, September 29, 2015 10:15:40 PM Yaowei Bai wrote:
> This patch makes audit_string_contains_control return bool to improve
> readability due to this particular function only using either one or
> zero as its return value.
>
> Signed-off-by: Yaowei Bai <bywxiaobai@xxxxxxx>
> ---
> include/linux/audit.h | 2 +-
> kernel/audit.c | 6 +++---
> 2 files changed, 4 insertions(+), 4 deletions(-)

Applied.

> diff --git a/include/linux/audit.h b/include/linux/audit.h
> index 69844b6..20eba1e 100644
> --- a/include/linux/audit.h
> +++ b/include/linux/audit.h
> @@ -457,7 +457,7 @@ extern struct audit_buffer *audit_log_start(struct
> audit_context *ctx, gfp_t gfp extern __printf(2, 3)
> void audit_log_format(struct audit_buffer *ab, const char *fmt, ...);
> extern void audit_log_end(struct audit_buffer *ab);
> -extern int audit_string_contains_control(const char *string,
> +extern bool audit_string_contains_control(const char *string,
> size_t len);
> extern void audit_log_n_hex(struct audit_buffer *ab,
> const unsigned char *buf,
> diff --git a/kernel/audit.c b/kernel/audit.c
> index 662c007..86d423c 100644
> --- a/kernel/audit.c
> +++ b/kernel/audit.c
> @@ -1566,14 +1566,14 @@ void audit_log_n_string(struct audit_buffer *ab,
> const char *string, * @string: string to be checked
> * @len: max length of the string to check
> */
> -int audit_string_contains_control(const char *string, size_t len)
> +bool audit_string_contains_control(const char *string, size_t len)
> {
> const unsigned char *p;
> for (p = string; p < (const unsigned char *)string + len; p++) {
> if (*p == '"' || *p < 0x21 || *p > 0x7e)
> - return 1;
> + return true;
> }
> - return 0;
> + return false;
> }
>
> /**

--
paul moore
www.paul-moore.com

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/