lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75VecDGzs=esey6hSDWMxvYPeeiy5T-9x6MNFaHspLq0ctA@mail.gmail.com>
Date:   Sun, 1 Oct 2017 17:59:20 +0300
From:   Andy Shevchenko <andy.shevchenko@...il.com>
To:     Kuppuswamy Sathyanarayanan 
        <sathyanarayanan.kuppuswamy@...ux.intel.com>
Cc:     Alessandro Zummo <a.zummo@...ertech.it>,
        "x86@...nel.org" <x86@...nel.org>,
        Wim Van Sebroeck <wim@...ana.be>,
        Ingo Molnar <mingo@...hat.com>,
        Alexandre Belloni <alexandre.belloni@...e-electrons.com>,
        Zha Qipeng <qipeng.zha@...el.com>,
        "H. Peter Anvin" <hpa@...or.com>,
        "dvhart@...radead.org" <dvhart@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Lee Jones <lee.jones@...aro.org>,
        Andy Shevchenko <andy@...radead.org>,
        Souvik Kumar Chakravarty <souvik.k.chakravarty@...el.com>,
        linux-rtc@...r.kernel.org, linux-watchdog@...r.kernel.org,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Platform Driver <platform-driver-x86@...r.kernel.org>,
        Sathyanarayanan Kuppuswamy Natarajan <sathyaosid@...il.com>
Subject: Re: [RFC v3 4/7] platform: x86: Add generic Intel IPC driver

On Tue, Sep 5, 2017 at 8:37 AM,
<sathyanarayanan.kuppuswamy@...ux.intel.com> wrote:
> From: Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@...ux.intel.com>
>
> Currently intel_scu_ipc.c, intel_pmc_ipc.c and intel_punit_ipc.c
> redundantly implements the same IPC features and has lot of code
> duplication between them. This driver addresses this issue by grouping
> the common IPC functionalities under the same driver.

> +static const char *ipc_dev_err_string(struct intel_ipc_dev *ipc_dev,
> +       int error)
> +{
> +       switch (error) {
> +       case IPC_DEV_ERR_NONE:
> +               return "No error";
> +       case IPC_DEV_ERR_CMD_NOT_SUPPORTED:
> +               return "Command not-supported/Invalid";
> +       case IPC_DEV_ERR_CMD_NOT_SERVICED:
> +               return "Command not-serviced/Invalid param";
> +       case IPC_DEV_ERR_UNABLE_TO_SERVICE:
> +               return "Unable-to-service/Cmd-timeout";
> +       case IPC_DEV_ERR_CMD_INVALID:
> +               return "Command-invalid/Cmd-locked";
> +       case IPC_DEV_ERR_CMD_FAILED:
> +               return "Command-failed/Invalid-VR-id";
> +       case IPC_DEV_ERR_EMSECURITY:
> +               return "Invalid Battery/VR-Error";
> +       case IPC_DEV_ERR_UNSIGNEDKERNEL:
> +               return "Unsigned kernel";
> +       default:
> +               return "Unknown Command";
> +       };
> +}

Since it's continuous list you can define an array of messages like

const char * const *errors = {
 [..._ERR_...] = "",
 ...

};

Also you can use enum in the header and define _ERR_MAX there.
Thus, code would be transformed to

if (error < _ERR_MAX)
 return errors[error];

return "Unknown Command";

-- 
With Best Regards,
Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ