Re: [PATCH 1/2] vmcore-dmesg/vmcore-dmesg.c: Fix shifting error reported by cppcheck

2019-09-10 Thread Bhupesh Sharma
On Tue, Sep 10, 2019 at 7:25 PM lijiang  wrote:
>
> 在 2019年09月10日 18:21, Bhupesh Sharma 写道:
> > Running 'cppcheck' static code analyzer (see cppcheck(1))
> >  on 'vmcore-dmesg/vmcore-dmesg.c' shows the following
> > shifting error:
> >
> > $ cppcheck  --enable=all  vmcore-dmesg/vmcore-dmesg.c
> > Checking vmcore-dmesg/vmcore-dmesg.c ...
> > [vmcore-dmesg/vmcore-dmesg.c:17]: (error) Shifting signed 32-bit value by 
> > 31 bits is undefined behaviour
> >
> > Fix the same via this patch.
> >
> > Cc: Lianbo Jiang 
> > Cc: Simon Horman 
> > Signed-off-by: Bhupesh Sharma 
> > ---
> >  vmcore-dmesg/vmcore-dmesg.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c
> > index 81c2a58..122e536 100644
> > --- a/vmcore-dmesg/vmcore-dmesg.c
> > +++ b/vmcore-dmesg/vmcore-dmesg.c
> > @@ -6,7 +6,7 @@ typedef Elf32_Nhdr Elf_Nhdr;
> >  extern const char *fname;
> >
> >  /* stole this macro from kernel printk.c */
> > -#define LOG_BUF_LEN_MAX (uint32_t)(1 << 31)
> > +#define LOG_BUF_LEN_MAX (uint32_t)(1U << 31)
> >
>
> This looks better. Thank you, Bhupesh.

Thanks for your review, Lianbo.

Regards,
Bhupesh

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


Re: [PATCH 1/2] vmcore-dmesg/vmcore-dmesg.c: Fix shifting error reported by cppcheck

2019-09-10 Thread lijiang
在 2019年09月10日 18:21, Bhupesh Sharma 写道:
> Running 'cppcheck' static code analyzer (see cppcheck(1))
>  on 'vmcore-dmesg/vmcore-dmesg.c' shows the following
> shifting error:
> 
> $ cppcheck  --enable=all  vmcore-dmesg/vmcore-dmesg.c
> Checking vmcore-dmesg/vmcore-dmesg.c ...
> [vmcore-dmesg/vmcore-dmesg.c:17]: (error) Shifting signed 32-bit value by 31 
> bits is undefined behaviour
> 
> Fix the same via this patch.
> 
> Cc: Lianbo Jiang 
> Cc: Simon Horman 
> Signed-off-by: Bhupesh Sharma 
> ---
>  vmcore-dmesg/vmcore-dmesg.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c
> index 81c2a58..122e536 100644
> --- a/vmcore-dmesg/vmcore-dmesg.c
> +++ b/vmcore-dmesg/vmcore-dmesg.c
> @@ -6,7 +6,7 @@ typedef Elf32_Nhdr Elf_Nhdr;
>  extern const char *fname;
>  
>  /* stole this macro from kernel printk.c */
> -#define LOG_BUF_LEN_MAX (uint32_t)(1 << 31)
> +#define LOG_BUF_LEN_MAX (uint32_t)(1U << 31)
> 

This looks better. Thank you, Bhupesh.

>  static void write_to_stdout(char *buf, unsigned int nr)
>  {
> 

___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec


[PATCH 1/2] vmcore-dmesg/vmcore-dmesg.c: Fix shifting error reported by cppcheck

2019-09-10 Thread Bhupesh Sharma
Running 'cppcheck' static code analyzer (see cppcheck(1))
 on 'vmcore-dmesg/vmcore-dmesg.c' shows the following
shifting error:

$ cppcheck  --enable=all  vmcore-dmesg/vmcore-dmesg.c
Checking vmcore-dmesg/vmcore-dmesg.c ...
[vmcore-dmesg/vmcore-dmesg.c:17]: (error) Shifting signed 32-bit value by 31 
bits is undefined behaviour

Fix the same via this patch.

Cc: Lianbo Jiang 
Cc: Simon Horman 
Signed-off-by: Bhupesh Sharma 
---
 vmcore-dmesg/vmcore-dmesg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c
index 81c2a58..122e536 100644
--- a/vmcore-dmesg/vmcore-dmesg.c
+++ b/vmcore-dmesg/vmcore-dmesg.c
@@ -6,7 +6,7 @@ typedef Elf32_Nhdr Elf_Nhdr;
 extern const char *fname;
 
 /* stole this macro from kernel printk.c */
-#define LOG_BUF_LEN_MAX (uint32_t)(1 << 31)
+#define LOG_BUF_LEN_MAX (uint32_t)(1U << 31)
 
 static void write_to_stdout(char *buf, unsigned int nr)
 {
-- 
2.17.1


___
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec