linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matteo Croce <mcroce@linux.microsoft.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Nathan Chancellor <natechancellor@gmail.com>,
	Arnd Bergmann <arnd@arndb.de>, Kees Cook <keescook@chromium.org>,
	linux-kernel@vger.kernel.org, Guenter Roeck <linux@roeck-us.net>,
	Pavel Tatashin <pasha.tatashin@soleen.com>,
	Petr Mladek <pmladek@suse.com>, Mike Rapoport <rppt@kernel.org>,
	Tyler Hicks <tyhicks@linux.microsoft.com>,
	Nick Desaulniers <ndesaulniers@google.com>,
	clang-built-linux@googlegroups.com
Subject: Re: [PATCH] reboot: Fix variable assignments in type_store
Date: Fri, 13 Nov 2020 01:41:32 +0100	[thread overview]
Message-ID: <CAFnufp00cGHi708s=6UG6H_HkM5-7_nX8SJ8=RVvgXKaai=LZA@mail.gmail.com> (raw)
In-Reply-To: <CAFnufp1j6ZzxLJA2x28BdxbTtnN_KtnXB49ibPcbze=B2ru3aA@mail.gmail.com>

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

  reply	other threads:[~2020-11-13  0:42 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-10 20:27 [PATCH v4] reboot: allow to specify reboot mode via sysfs Matteo Croce
2020-11-12  3:50 ` [PATCH] reboot: Fix variable assignments in type_store Nathan Chancellor
2020-11-12 11:26   ` Matteo Croce
2020-11-12 17:49     ` Nathan Chancellor
2020-11-12 17:59       ` Matteo Croce
2020-11-12 18:09         ` Nathan Chancellor
2020-11-12 23:13   ` Andrew Morton
2020-11-13  0:20     ` Matteo Croce
2020-11-13  0:41       ` Matteo Croce [this message]
2020-11-13  1:18       ` Andrew Morton
2020-11-13  1:38         ` Matteo Croce
2020-11-13  2:46           ` Andrew Morton
2020-11-13  2:58             ` Matteo Croce
2020-11-13 20:06               ` Petr Mladek
2020-11-13 21:28                 ` Matteo Croce
2020-11-18 11:47                   ` Petr Mladek
2020-11-13 15:56   ` Petr Mladek
2021-02-22 10:03 ` [PATCH v4] reboot: allow to specify reboot mode via sysfs Pavel Machek
2021-02-22 13:12   ` Matteo Croce

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFnufp00cGHi708s=6UG6H_HkM5-7_nX8SJ8=RVvgXKaai=LZA@mail.gmail.com' \
    --to=mcroce@linux.microsoft.com \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=clang-built-linux@googlegroups.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=natechancellor@gmail.com \
    --cc=ndesaulniers@google.com \
    --cc=pasha.tatashin@soleen.com \
    --cc=pmladek@suse.com \
    --cc=rppt@kernel.org \
    --cc=tyhicks@linux.microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).