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.zh...@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

_______________________________________________
https://lists.nongnu.org/mailman/listinfo/dmidecode-devel

Reply via email to