All of lore.kernel.org
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: xen-devel@lists.xenproject.org
Cc: Juergen Gross <jgross@suse.com>, Jan Beulich <jbeulich@suse.com>
Subject: [PATCH v4 35/53] xen/drivers/passthrough/pci.c: let custom parameter parsing routines return errno
Date: Wed, 23 Aug 2017 19:34:28 +0200	[thread overview]
Message-ID: <20170823173446.24801-36-jgross@suse.com> (raw)
In-Reply-To: <20170823173446.24801-1-jgross@suse.com>

Modify the custom parameter parsing routines in:

xen/drivers/passthrough/pci.c

to indicate whether the parameter value was parsed successfully.

Cc: Jan Beulich <jbeulich@suse.com>
Signed-off-by: Juergen Gross <jgross@suse.com>
---
V4:
- differentiate error return values (Jan Beulich)
- drop pointless test for input parameter being NULL (Jan Beulich)

V3:
- cosmetic changes (Jan Beulich)
- dont modify option value in parsing funtion
---
 xen/drivers/passthrough/pci.c | 38 ++++++++++++++++++++++++--------------
 1 file changed, 24 insertions(+), 14 deletions(-)

diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
index 27bdb7163c..ce22aa41a4 100644
--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -149,17 +149,20 @@ static struct phantom_dev {
 } phantom_devs[8];
 static unsigned int nr_phantom_devs;
 
-static void __init parse_phantom_dev(char *str) {
-    const char *s = str;
+static int __init parse_phantom_dev(const char *str)
+{
+    const char *s;
     unsigned int seg, bus, slot;
     struct phantom_dev phantom;
 
-    if ( !s || !*s || nr_phantom_devs >= ARRAY_SIZE(phantom_devs) )
-        return;
+    if ( !*str )
+        return -EINVAL;
+    if ( nr_phantom_devs >= ARRAY_SIZE(phantom_devs) )
+        return -E2BIG;
 
-    s = parse_pci(s, &seg, &bus, &slot, NULL);
+    s = parse_pci(str, &seg, &bus, &slot, NULL);
     if ( !s || *s != ',' )
-        return;
+        return -EINVAL;
 
     phantom.seg = seg;
     phantom.bus = bus;
@@ -170,10 +173,12 @@ static void __init parse_phantom_dev(char *str) {
     case 1: case 2: case 4:
         if ( *s )
     default:
-            return;
+            return -EINVAL;
     }
 
     phantom_devs[nr_phantom_devs++] = phantom;
+
+    return 0;
 }
 custom_param("pci-phantom", parse_phantom_dev);
 
@@ -189,9 +194,10 @@ static u16 __read_mostly bridge_ctl_mask;
  *   perr                       don't suppress parity errors (default)
  *   no-perr                    suppress parity errors
  */
-static void __init parse_pci_param(char *s)
+static int __init parse_pci_param(const char *s)
 {
-    char *ss;
+    const char *ss;
+    int rc = 0;
 
     do {
         bool_t on = !!strncmp(s, "no-", 3);
@@ -201,19 +207,21 @@ static void __init parse_pci_param(char *s)
             s += 3;
 
         ss = strchr(s, ',');
-        if ( ss )
-            *ss = '\0';
+        if ( !ss )
+            ss = strchr(s, '\0');
 
-        if ( !strcmp(s, "serr") )
+        if ( !strncmp(s, "serr", ss - s) )
         {
             cmd_mask = PCI_COMMAND_SERR;
             brctl_mask = PCI_BRIDGE_CTL_SERR | PCI_BRIDGE_CTL_DTMR_SERR;
         }
-        else if ( !strcmp(s, "perr") )
+        else if ( !strncmp(s, "perr", ss - s) )
         {
             cmd_mask = PCI_COMMAND_PARITY;
             brctl_mask = PCI_BRIDGE_CTL_PARITY;
         }
+        else
+            rc = -EINVAL;
 
         if ( on )
         {
@@ -227,7 +235,9 @@ static void __init parse_pci_param(char *s)
         }
 
         s = ss + 1;
-    } while ( ss );
+    } while ( *ss );
+
+    return rc;
 }
 custom_param("pci", parse_pci_param);
 
-- 
2.12.3


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

  parent reply	other threads:[~2017-08-23 17:36 UTC|newest]

Thread overview: 75+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-23 17:33 [PATCH v4 00/53] Support for modifying parameters at runtime Juergen Gross
2017-08-23 17:33 ` [PATCH v4 01/53] xen: add an optional string end parameter to parse_bool() Juergen Gross
2017-08-24  6:04   ` Tian, Kevin
2017-08-24 11:47   ` Wei Liu
2017-08-24 15:33   ` Jan Beulich
2017-08-24 15:43   ` Andrew Cooper
2017-08-25  8:31     ` Juergen Gross
2017-08-25  8:50       ` Jan Beulich
     [not found]   ` <599F0DFB020000780017365B@suse.com>
2017-08-24 16:28     ` Juergen Gross
2017-08-23 17:33 ` [PATCH v4 02/53] xen/arch/arm/acpi/boot.c: let custom parameter parsing routines return errno Juergen Gross
2017-08-23 17:33 ` [PATCH v4 03/53] xen/arch/arm/domain_build.c: " Juergen Gross
2017-08-23 17:33 ` [PATCH v4 04/53] xen/arch/arm/traps.c: " Juergen Gross
2017-08-23 17:33 ` [PATCH v4 05/53] xen/arch/x86/apic.c: " Juergen Gross
2017-08-23 17:33 ` [PATCH v4 06/53] xen/arch/x86/cpu/mcheck/mce.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 07/53] xen/arch/x86/cpu/vpmu.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 08/53] xen/arch/x86/dom0_build.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 09/53] xen/arch/x86/genapic/probe.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 10/53] xen/arch/x86/hvm/viridian.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 11/53] xen/arch/x86/hvm/vmx/vmcs.c: " Juergen Gross
2017-08-24  6:07   ` Tian, Kevin
2017-08-23 17:34 ` [PATCH v4 12/53] xen/arch/x86/io_apic.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 13/53] xen/arch/x86/irq.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 14/53] xen/arch/x86/microcode.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 15/53] xen/arch/x86/mm.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 16/53] xen/arch/x86/nmi.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 17/53] xen/arch/x86/numa.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 18/53] xen/arch/x86/oprofile/nmi_int.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 19/53] xen/arch/x86/psr.c: " Juergen Gross
2017-08-24 15:35   ` Jan Beulich
     [not found]   ` <599F0E57020000780017365E@suse.com>
2017-08-24 16:27     ` Juergen Gross
2017-08-25  8:17       ` Jan Beulich
     [not found]       ` <599FF92102000078001738F2@suse.com>
2017-08-25  8:33         ` Juergen Gross
2017-08-23 17:34 ` [PATCH v4 20/53] xen/arch/x86/setup.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 21/53] xen/arch/x86/shutdown.c: " Juergen Gross
2017-08-25  8:40   ` Jan Beulich
2017-08-23 17:34 ` [PATCH v4 22/53] xen/arch/x86/time.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 23/53] xen/arch/x86/x86_64/mmconfig-shared.c: " Juergen Gross
2017-08-25  8:41   ` Jan Beulich
2017-08-23 17:34 ` [PATCH v4 24/53] xen/common/core_parking.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 25/53] xen/common/domain.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 26/53] xen/common/efi/boot.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 27/53] xen/common/kexec.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 28/53] xen/common/memory.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 29/53] xen/common/sched_credit2.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 30/53] xen/drivers/acpi/tables.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 31/53] xen/drivers/char/console.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 32/53] xen/drivers/cpufreq/cpufreq.c: " Juergen Gross
2017-08-25  8:42   ` Jan Beulich
2017-08-23 17:34 ` [PATCH v4 33/53] xen/drivers/passthrough/amd/iommu_acpi.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 34/53] xen/drivers/passthrough/iommu.c: " Juergen Gross
2017-08-25  8:43   ` Jan Beulich
2017-08-23 17:34 ` Juergen Gross [this message]
2017-08-25  8:44   ` [PATCH v4 35/53] xen/drivers/passthrough/pci.c: " Jan Beulich
2017-08-23 17:34 ` [PATCH v4 36/53] xen/drivers/passthrough/vtd/dmar.c: " Juergen Gross
2017-08-24  6:09   ` Tian, Kevin
2017-08-23 17:34 ` [PATCH v4 37/53] xen/drivers/passthrough/vtd/quirks.c: " Juergen Gross
2017-08-24  6:10   ` Tian, Kevin
2017-08-23 17:34 ` [PATCH v4 38/53] xen/drivers/video/vesa.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 39/53] xen/xsm/flask/flask_op.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 40/53] xen: check parameter validity when parsing command line Juergen Gross
2017-08-24 14:27   ` Wei Liu
2017-08-23 17:34 ` [PATCH v4 41/53] xen/arch/x86/apic.c: remove custom_param() error messages Juergen Gross
2017-08-23 17:34 ` [PATCH v4 42/53] xen/arch/x86/cpu/mcheck/mce.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 43/53] xen/arch/x86/hvm/viridian.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 44/53] xen/arch/x86/io_apic.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 45/53] xen/common/kexec.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 46/53] xen/common/sched_credit2.c: " Juergen Gross
2017-08-23 17:34 ` [PATCH v4 47/53] xen: carve out a generic parsing function from _cmdline_parse() Juergen Gross
2017-08-23 17:34 ` [PATCH v4 48/53] xen: add basic support for runtime parameter changing Juergen Gross
2017-08-23 17:34 ` [PATCH v4 49/53] xen: add hypercall for setting parameters at runtime Juergen Gross
2017-08-24 14:28   ` Wei Liu
2017-08-23 17:34 ` [PATCH v4 50/53] libxc: add function to set hypervisor parameters Juergen Gross
2017-08-23 17:34 ` [PATCH v4 51/53] libxl: add libxl_set_parameters() function Juergen Gross
2017-08-23 17:34 ` [PATCH v4 52/53] xl: add new xl command set-parameters Juergen Gross
2017-08-23 17:34 ` [PATCH v4 53/53] xen: make some console related parameters settable at runtime Juergen Gross

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=20170823173446.24801-36-jgross@suse.com \
    --to=jgross@suse.com \
    --cc=jbeulich@suse.com \
    --cc=xen-devel@lists.xenproject.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.