[RFC PATCH 2/3] net/dev/core.c: use ksa_parse_ints instead of get_options

From: Ilya Matveychikov
Date: Tue Sep 19 2017 - 04:32:59 EST


Signed-off-by: Ilya V. Matveychikov <matvejchikov@xxxxxxxxx>
---
net/core/dev.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 8515f8f..acda9ac 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -144,6 +144,7 @@
#include <linux/netfilter_ingress.h>
#include <linux/crash_dump.h>
#include <linux/sctp.h>
+#include <linux/small_array.h>

#include "net-sysfs.h"

@@ -645,23 +646,18 @@ unsigned long netdev_boot_base(const char *prefix, int unit)
*/
int __init netdev_boot_setup(char *str)
{
- int ints[5];
- struct ifmap map;
+ struct ifmap map = { 0 };
+ KSA_DECLARE(ints, int, 4);

- str = get_options(str, ARRAY_SIZE(ints), ints);
+ str = ksa_parse_ints(str, KSA(&ints));
if (!str || !*str)
return 0;

/* Save settings */
- memset(&map, 0, sizeof(map));
- if (ints[0] > 0)
- map.irq = ints[1];
- if (ints[0] > 1)
- map.base_addr = ints[2];
- if (ints[0] > 2)
- map.mem_start = ints[3];
- if (ints[0] > 3)
- map.mem_end = ints[4];
+ map.irq = KSA_GET(&ints, 0, 0);
+ map.base_addr = KSA_GET(&ints, 1, 0);
+ map.mem_start = KSA_GET(&ints, 2, 0);
+ map.mem_end = KSA_GET(&ints, 3, 0);

/* Add new entry to the list */
return netdev_boot_setup_add(str, &map);
--
2.7.4