Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp778433pxb; Thu, 12 Nov 2020 16:43:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJyi7h8drs3Wn0e9RbwYDpSLe2NYp6BYiUeyjEoWAGwDkZE+EYbDBTwpMXTR4AtLZYaUp9Ge X-Received: by 2002:a17:906:4748:: with SMTP id j8mr1908488ejs.22.1605228237970; Thu, 12 Nov 2020 16:43:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605228237; cv=none; d=google.com; s=arc-20160816; b=ztyozCVwKAsdKVOlqxJRnGxt1Dfw+PRFjyJh38eW4+0XE3TqhCS3nYBciP2Kx5fuYW XOc0+FRqARD1M7L7hZujvQuM41R3o1RUSEcuA68Lo2WTo+8JxDsd2QOpLvtrbj25qhbZ oXS5vWsWHkBU/yBMyfdpYP4aT+u7vWWdqd7iqVVv7S5w1hFXLl1LBqqU7P2BeI2ic7QE WyzbaSthU4sjc6B6IOYXMVrRXhgry8PqcwJxKwjBVZPHBpViTwm/gGyujo3lyJsm8R8T hvhRWhQb+fVjKoVvw5PFJKaxhOOGsPMdvFrpJzyDEimTMwoQlZyFueQZ49/rP7I/FdFR AH3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature:dkim-filter; bh=BLyq9e6WMsX58xvPzqQvR0qZa+PPwQVF0bTZmr9IcaE=; b=XWtSJcLz2NmM6e3rOvlGPihs80C8tMAfF8Y5tuvfOilUfyNX+wlc3IdcOFUrhPJgf+ hxUzLGflXqyn9ndA/gnofkXEJDfwqdZiQ3BFXZwvhMd1EQPhzLZU2cRRHqM+kKIZNf7F kyCKGF5/Yip4u/NGNuoX4kljo9Jyhj+XhglH55IqYwXL2JAjyQKUjMP9bhWZcjOYKvRS AMsfa40LBPhsqAf4pgZO6y2IMXVMTvNbHgdqjRgOZbKEoV9t5biqMs4fzXHdRWvSbiQh wPk2V3dhB8jCl671yjA/AABVkTc4scbupUIxEJzCfO39+Cvn4K+eyPQq3GiFSEXCodPQ /N0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=jB9OEBKJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si2609119ejg.330.2020.11.12.16.43.35; Thu, 12 Nov 2020 16:43:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=jB9OEBKJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726024AbgKMAmK (ORCPT + 99 others); Thu, 12 Nov 2020 19:42:10 -0500 Received: from linux.microsoft.com ([13.77.154.182]:47212 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725929AbgKMAmJ (ORCPT ); Thu, 12 Nov 2020 19:42:09 -0500 Received: from mail-qv1-f45.google.com (mail-qv1-f45.google.com [209.85.219.45]) by linux.microsoft.com (Postfix) with ESMTPSA id 039BF20C288A for ; Thu, 12 Nov 2020 16:42:08 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 039BF20C288A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1605228129; bh=BLyq9e6WMsX58xvPzqQvR0qZa+PPwQVF0bTZmr9IcaE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=jB9OEBKJWqCg0GF5/+v9yBMLJ2hRPDmeBNIuKyPWufGd2V2eu/vh2ANhECGRfffUs 0hxwbkF/XQinH8TOveTkOIqp2Rj+H3as0tq4mW5w4sptyKFBjOkwlx5QwW5URBWTAG PK+eM18HYP07srrTOIkV5m5BjpXwlsBXCXV/CT70= Received: by mail-qv1-f45.google.com with SMTP id q7so3810392qvt.12 for ; Thu, 12 Nov 2020 16:42:08 -0800 (PST) X-Gm-Message-State: AOAM530XsjOxYfdCDk3JRVEgny39rayOCWmGLPWjacur/axw9MbPJA9J vd04+GR7nBjgyf7SJFcAyqem5T1zEy1jkHahEFE= X-Received: by 2002:a0c:cb04:: with SMTP id o4mr2565193qvk.15.1605228128037; Thu, 12 Nov 2020 16:42:08 -0800 (PST) MIME-Version: 1.0 References: <20201110202746.9690-1-mcroce@linux.microsoft.com> <20201112035023.974748-1-natechancellor@gmail.com> <20201112151320.e0153ace2f2eb5b59eabbdcb@linux-foundation.org> In-Reply-To: From: Matteo Croce Date: Fri, 13 Nov 2020 01:41:32 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] reboot: Fix variable assignments in type_store To: Andrew Morton Cc: Nathan Chancellor , Arnd Bergmann , Kees Cook , linux-kernel@vger.kernel.org, Guenter Roeck , Pavel Tatashin , Petr Mladek , Mike Rapoport , Tyler Hicks , Nick Desaulniers , clang-built-linux@googlegroups.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 13, 2020 at 1:20 AM Matteo Croce wrote: > > On Fri, Nov 13, 2020 at 12:13 AM Andrew Morton > wrote: > > > > On Wed, 11 Nov 2020 20:50:23 -0700 Nathan Chancellor 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 [ $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 [ $i = $j ] || echo "type $i = $j" > done > > for i in $(seq 0 $(nproc --ignore=1)); do > echo $i > cpu > read j [ $i = $j ] || echo "cpu $i = $j" > done > > for i in 0 1; do > echo $i >force > read j [ $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 -- per aspera ad upstream