* [PATCH iproute2-next] utils: move parse_percent() to tc_util
@ 2019-06-28 16:03 Andrea Claudi
2019-06-28 23:07 ` David Ahern
0 siblings, 1 reply; 2+ messages in thread
From: Andrea Claudi @ 2019-06-28 16:03 UTC (permalink / raw)
To: netdev; +Cc: stephen, dsahern
As parse_percent() is used only in tc.
This reduces ip, bridge and genl binaries size:
$ bloat-o-meter -t bridge/bridge bridge/bridge.new
add/remove: 0/1 grow/shrink: 0/0 up/down: 0/-109 (-109)
Total: Before=50973, After=50864, chg -0.21%
$ bloat-o-meter -t genl/genl genl/genl.new
add/remove: 0/1 grow/shrink: 0/0 up/down: 0/-109 (-109)
Total: Before=30298, After=30189, chg -0.36%
$ bloat-o-meter ip/ip ip/ip.new
add/remove: 0/1 grow/shrink: 0/0 up/down: 0/-109 (-109)
Total: Before=674164, After=674055, chg -0.02%
Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
---
include/utils.h | 1 -
lib/utils.c | 16 ----------------
tc/tc_util.c | 16 ++++++++++++++++
tc/tc_util.h | 1 +
4 files changed, 17 insertions(+), 17 deletions(-)
diff --git a/include/utils.h b/include/utils.h
index ec0231f9772d0..1d9c11276bbe6 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -146,7 +146,6 @@ int get_addr_rta(inet_prefix *dst, const struct rtattr *rta, int family);
int get_addr_ila(__u64 *val, const char *arg);
int read_prop(const char *dev, char *prop, long *value);
-int parse_percent(double *val, const char *str);
int get_hex(char c);
int get_integer(int *val, const char *arg, int base);
int get_unsigned(unsigned *val, const char *arg, int base);
diff --git a/lib/utils.c b/lib/utils.c
index be0f11b00280d..5da9a47848966 100644
--- a/lib/utils.c
+++ b/lib/utils.c
@@ -101,22 +101,6 @@ out:
return -1;
}
-/* Parse a percent e.g: '30%'
- * return: 0 = ok, -1 = error, 1 = out of range
- */
-int parse_percent(double *val, const char *str)
-{
- char *p;
-
- *val = strtod(str, &p) / 100.;
- if (*val == HUGE_VALF || *val == HUGE_VALL)
- return 1;
- if (*p && strcmp(p, "%"))
- return -1;
-
- return 0;
-}
-
int get_hex(char c)
{
if (c >= 'A' && c <= 'F')
diff --git a/tc/tc_util.c b/tc/tc_util.c
index e5d15281581df..53d15e08e9734 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -190,6 +190,22 @@ static const struct rate_suffix {
{ NULL }
};
+/* Parse a percent e.g: '30%'
+ * return: 0 = ok, -1 = error, 1 = out of range
+ */
+int parse_percent(double *val, const char *str)
+{
+ char *p;
+
+ *val = strtod(str, &p) / 100.;
+ if (*val == HUGE_VALF || *val == HUGE_VALL)
+ return 1;
+ if (*p && strcmp(p, "%"))
+ return -1;
+
+ return 0;
+}
+
static int parse_percent_rate(char *rate, size_t len,
const char *str, const char *dev)
{
diff --git a/tc/tc_util.h b/tc/tc_util.h
index 825fea36a0809..eb4b60db3fdd7 100644
--- a/tc/tc_util.h
+++ b/tc/tc_util.h
@@ -101,6 +101,7 @@ int print_tc_classid(char *buf, int len, __u32 h);
char *sprint_tc_classid(__u32 h, char *buf);
int tc_print_police(FILE *f, struct rtattr *tb);
+int parse_percent(double *val, const char *str);
int parse_police(int *argc_p, char ***argv_p, int tca_id, struct nlmsghdr *n);
int parse_action_control(int *argc_p, char ***argv_p,
--
2.20.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH iproute2-next] utils: move parse_percent() to tc_util
2019-06-28 16:03 [PATCH iproute2-next] utils: move parse_percent() to tc_util Andrea Claudi
@ 2019-06-28 23:07 ` David Ahern
0 siblings, 0 replies; 2+ messages in thread
From: David Ahern @ 2019-06-28 23:07 UTC (permalink / raw)
To: Andrea Claudi, netdev; +Cc: stephen, dsahern
On 6/28/19 10:03 AM, Andrea Claudi wrote:
> As parse_percent() is used only in tc.
>
> This reduces ip, bridge and genl binaries size:
>
> $ bloat-o-meter -t bridge/bridge bridge/bridge.new
> add/remove: 0/1 grow/shrink: 0/0 up/down: 0/-109 (-109)
> Total: Before=50973, After=50864, chg -0.21%
>
> $ bloat-o-meter -t genl/genl genl/genl.new
> add/remove: 0/1 grow/shrink: 0/0 up/down: 0/-109 (-109)
> Total: Before=30298, After=30189, chg -0.36%
>
> $ bloat-o-meter ip/ip ip/ip.new
> add/remove: 0/1 grow/shrink: 0/0 up/down: 0/-109 (-109)
> Total: Before=674164, After=674055, chg -0.02%
>
> Signed-off-by: Andrea Claudi <aclaudi@redhat.com>
> ---
> include/utils.h | 1 -
> lib/utils.c | 16 ----------------
> tc/tc_util.c | 16 ++++++++++++++++
> tc/tc_util.h | 1 +
> 4 files changed, 17 insertions(+), 17 deletions(-)
>
applied to iproute2-next. Thanks
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-06-28 23:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-28 16:03 [PATCH iproute2-next] utils: move parse_percent() to tc_util Andrea Claudi
2019-06-28 23:07 ` David Ahern
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).