lkml.org 
[lkml]   [2020]   [Nov]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] reboot: Fix variable assignments in type_store
On Fri, Nov 13, 2020 at 1:20 AM Matteo Croce <mcroce@linux.microsoft.com> wrote:
>
> On Fri, Nov 13, 2020 at 12:13 AM Andrew Morton
> <akpm@linux-foundation.org> wrote:
> >
> > On Wed, 11 Nov 2020 20:50:23 -0700 Nathan Chancellor <natechancellor@gmail.com> wrote:
> >
> > > Clang warns:
> > >
> > > kernel/reboot.c:707:17: warning: implicit conversion from enumeration
> > > type 'enum reboot_type' to different enumeration type 'enum reboot_mode'
> > > [-Wenum-conversion]
> > > reboot_mode = BOOT_TRIPLE;
> > > ~ ^~~~~~~~~~~
> > >
> > > ...
> > >
> > > --- a/kernel/reboot.c
> > > +++ b/kernel/reboot.c
> > > @@ -704,19 +704,19 @@ static ssize_t type_store(struct kobject *kobj, struct kobj_attribute *attr,
> > > return -EPERM;
> > >
> > > if (!strncmp(buf, BOOT_TRIPLE_STR, strlen(BOOT_TRIPLE_STR)))
> > > - reboot_mode = BOOT_TRIPLE;
> > > + reboot_type = BOOT_TRIPLE;
> > > else if (!strncmp(buf, BOOT_KBD_STR, strlen(BOOT_KBD_STR)))
> > > - reboot_mode = BOOT_KBD;
> > > + reboot_type = BOOT_KBD;
> > > else if (!strncmp(buf, BOOT_BIOS_STR, strlen(BOOT_BIOS_STR)))
> > > - reboot_mode = BOOT_BIOS;
> > > + reboot_type = BOOT_BIOS;
> > > else if (!strncmp(buf, BOOT_ACPI_STR, strlen(BOOT_ACPI_STR)))
> > > - reboot_mode = BOOT_ACPI;
> > > + reboot_type = BOOT_ACPI;
> > > else if (!strncmp(buf, BOOT_EFI_STR, strlen(BOOT_EFI_STR)))
> > > - reboot_mode = BOOT_EFI;
> > > + reboot_type = BOOT_EFI;
> > > else if (!strncmp(buf, BOOT_CF9_FORCE_STR, strlen(BOOT_CF9_FORCE_STR)))
> > > - reboot_mode = BOOT_CF9_FORCE;
> > > + reboot_type = BOOT_CF9_FORCE;
> > > else if (!strncmp(buf, BOOT_CF9_SAFE_STR, strlen(BOOT_CF9_SAFE_STR)))
> > > - reboot_mode = BOOT_CF9_SAFE;
> > > + reboot_type = BOOT_CF9_SAFE;
> > > else
> > > return -EINVAL;
> >
> > This is a fairly dramatic change to the original patch, but it eyeballs
> > OK.
> >
> > Matteo, could you please comment? And preferably retest?
> >
>
> Hi,
>
> I reviewed the patch and it looks good to me.
> I tested it with this script which passes now with Nathan's fix:
>
> for i in cold warm hard soft gpio; do
> echo $i > mode
> read j <mode
> [ $i = $j ] || echo "mode $i = $j"
> done
>
> for i in bios acpi kbd triple efi cf9_force cf9_safe; do
> echo $i > type
> read j <type
> [ $i = $j ] || echo "type $i = $j"
> done
>
> for i in $(seq 0 $(nproc --ignore=1)); do
> echo $i > cpu
> read j <cpu
> [ $i = $j ] || echo "cpu $i = $j"
> done
>
> for i in 0 1; do
> echo $i >force
> read j <force
> [ $i = $j ] || echo "force $i = $j"
> done
>
> While writing the script I found that in the documentation I left for
> 'type' the values from
> Documentation/admin-guide/kernel-parameters.txt, which is 'pci' for
> cf9_force reboot.
> While at it, should we update the doc with the values 'cf9_force' and
> 'cf9_safe', or rename to 'pci' and 'pci_safe' to be coherent with the
> kernel cmdline?
>
> In any case, kernel-parameters.txt doesn't mention that reboot=q does
> the 'cf9_safe' reboot type, so it must be fixed anyway.
>
> Regards,
> --
> per aspera ad upstream

Reviewed-and-tested-by: Matteo Croce <mcroce@microsoft.com>

--
per aspera ad upstream

\
 
 \ /
  Last update: 2020-11-13 01:43    [W:0.076 / U:0.760 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site