dmidecode-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [dmidecode] [PATCH] dmidecode: Fix the condition error in ascii_filt


From: Jean Delvare
Subject: Re: [dmidecode] [PATCH] dmidecode: Fix the condition error in ascii_filter
Date: Tue, 5 Jan 2021 10:36:04 +0100

Hi Tianjia,

On Tue,  5 Jan 2021 12:12:15 +0800, Tianjia Zhang wrote:
> The normal printable ASCII range is 32 to 127 (not included),
> so fix the error in this if condition.
> 
> Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com>
> ---
>  dmidecode.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/dmidecode.c b/dmidecode.c
> index 27d5494..864a193 100644
> --- a/dmidecode.c
> +++ b/dmidecode.c
> @@ -116,7 +116,7 @@ static void ascii_filter(char *bp, size_t len)
>       size_t i;
>  
>       for (i = 0; i < len; i++)
> -             if (bp[i] < 32 || bp[i] == 127)
> +             if (bp[i] < 32 || bp[i] >= 127)
>                       bp[i] = '.';
>  }
>  

The original code was assuming that the char type was signed. It is the
case for me (that's the default for gcc on x86), but apparently there
is no guarantee that this is always the case. Your test works for both
signed and unsigned so I'll use that. Thanks for your contribution.

-- 
Jean Delvare
SUSE L3 Support



reply via email to

[Prev in Thread] Current Thread [Next in Thread]