From patchwork Thu Aug 23 01:01:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mahesh Bandewar X-Patchwork-Id: 961109 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bandewar.net Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bandewar-net.20150623.gappssmtp.com header.i=@bandewar-net.20150623.gappssmtp.com header.b="joXTDWcg"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41wmMS0qBKz9s3C for ; Thu, 23 Aug 2018 11:01:40 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726191AbeHWE2o (ORCPT ); Thu, 23 Aug 2018 00:28:44 -0400 Received: from mail-pf1-f193.google.com ([209.85.210.193]:35997 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725727AbeHWE2o (ORCPT ); Thu, 23 Aug 2018 00:28:44 -0400 Received: by mail-pf1-f193.google.com with SMTP id b11-v6so1805636pfo.3 for ; Wed, 22 Aug 2018 18:01:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bandewar-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=CA+mtCZX9dFkrkIrZqa77SYmaJeZweels7SS5a38Uh4=; b=joXTDWcgki9m6xW6hZbMogiVtVl0RU+AA3OyAmoUff10vg8S8fImB3H6XhVdkB7rFw IGLjKNuJra10TXfjqoawnmZgOsBh8cKXUwXSPI7VL42O6tXBjgehSZMcy9ZBUrTYuRVK zojR0yRf1GuvIKmR5FnbLehkXMvN+g2gH9rooVGVTAhQJF5Cp3RGhGRHIc5HKQexlgf5 FRbzDotx88yGKSOY2yjR6ZPx6cvo1teSHyA6R3z+c/b14tBUiDqv1Nw9ZgfD8t2yqI4i mELGAyeI9BTBBkd2lEKrjq2M8Z936Uxm9quJD5J/wRG6X+Ll6o3eTj3mZedcQVSQJGMw vW+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=CA+mtCZX9dFkrkIrZqa77SYmaJeZweels7SS5a38Uh4=; b=iCWRpfQfwYZdkXo4VtHG9nXOL5AkAtbNVY+3naKJgiUD3ytspdmB/83wCsFsbUz7/B cIW1gJmXVJsQ8rkLg+m16CZhDEUppK3OzgUy/By9EQ3NyrJKQfTBH6OHh17G9x8NrXVv mXA+SRhoa+FJYguVw9EHjNACLFQPXO1byQlgsH3A4xz9BGRVzqvf4rcy1DVkDEeV6Tec rJX1AVOa2k8ZgrkIaCpX+AewIaSWZIRnExaaSfFH9/GRbJO9bvTTx4Z80bx4V+lt3izm RSxWAP1zM9vdFc6WY1WG0Fdw+vMwqjp65ALWchyCZ/WZRsNG5QnES9WUh7rzYzbA83sx ZzOw== X-Gm-Message-State: AOUpUlGcUV+7XVW8WsbNmWoG+FTLM1rved6ZM5SUdyZ/fqGRNVARsoX1 DvK8N6AgVMnNkbdo2zuImZ1b93QVli4= X-Google-Smtp-Source: AA+uWPwC6E8w3ju9njgmRddTsc/N33l9xdtv4sh9KCjfDmFG9a6qn2StiQbZ7pJmqSzJJFCyK1NcOg== X-Received: by 2002:a62:dbc5:: with SMTP id f188-v6mr60941225pfg.182.1534986097216; Wed, 22 Aug 2018 18:01:37 -0700 (PDT) Received: from localhost ([2620:15c:2c4:201:c7f9:6225:a527:f3a4]) by smtp.gmail.com with ESMTPSA id a16-v6sm2729681pgv.29.2018.08.22.18.01.36 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 22 Aug 2018 18:01:36 -0700 (PDT) From: Mahesh Bandewar To: Stephen Hemminger Cc: netdev , Mahesh Bandewar Subject: [PATCHv3 iproute2 1/2] ipmaddr: use preferred_family when given Date: Wed, 22 Aug 2018 18:01:34 -0700 Message-Id: <20180823010134.147851-1-mahesh@bandewar.net> X-Mailer: git-send-email 2.19.0.rc0.228.g281dcd1b4d0-goog MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Mahesh Bandewar When creating socket() AF_INET is used irrespective of the family that is given at the command-line (with -4, -6, or -0). This change will open the socket with the preferred family. Signed-off-by: Mahesh Bandewar --- ip/ipmaddr.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ip/ipmaddr.c b/ip/ipmaddr.c index a48499029e17..abf83784d0df 100644 --- a/ip/ipmaddr.c +++ b/ip/ipmaddr.c @@ -289,6 +289,7 @@ static int multiaddr_list(int argc, char **argv) static int multiaddr_modify(int cmd, int argc, char **argv) { struct ifreq ifr = {}; + int family; int fd; if (cmd == RTM_NEWADDR) @@ -324,7 +325,17 @@ static int multiaddr_modify(int cmd, int argc, char **argv) exit(-1); } - fd = socket(AF_INET, SOCK_DGRAM, 0); + switch (preferred_family) { + case AF_INET6: + case AF_PACKET: + case AF_INET: + family = preferred_family; + break; + default: + family = AF_INET; + } + + fd = socket(family, SOCK_DGRAM, 0); if (fd < 0) { perror("Cannot create socket"); exit(1); From patchwork Thu Aug 23 01:01:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mahesh Bandewar X-Patchwork-Id: 961110 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=bandewar.net Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=bandewar-net.20150623.gappssmtp.com header.i=@bandewar-net.20150623.gappssmtp.com header.b="sCzmaqFj"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 41wmMV4jZnz9s3C for ; Thu, 23 Aug 2018 11:01:42 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726264AbeHWE2r (ORCPT ); Thu, 23 Aug 2018 00:28:47 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:33200 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725727AbeHWE2r (ORCPT ); Thu, 23 Aug 2018 00:28:47 -0400 Received: by mail-pl0-f66.google.com with SMTP id 60-v6so1320932ple.0 for ; Wed, 22 Aug 2018 18:01:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bandewar-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jRMoEosdYkJRFAL47dyRt+GrUyxqGcF0we+O1bJyfrY=; b=sCzmaqFjUtTJJg8n9iU9Hpi7h/CHpQFigkFCCuoETtvig3DmG4LyPMaVajzK3GUgYc 4Apw9mRZ8zfhYrLW5keajNqxdQvtmYJcUI3Pze1JpojUyZFJcSGBfDhx7TiLv+BmTADu FAWssScCUrA4ZGqrM7lH3jdYJT4l3tQ4M6TJ4dXNGGWT1Vfpv78x8aMT/grz8C8/FZyA db2R+TUmTdIT4HAw4JQe3d2U8ItFWdyqnVEyfQRxAdjTi1gyLg/b16NwGX1IfxWHATy8 KC3QksmDCz9IVZb5CxUaZx1f8KIwPG32/kI47PV41y/l1fpXn/s4yWgzWBBSN4K/Tna0 QkbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jRMoEosdYkJRFAL47dyRt+GrUyxqGcF0we+O1bJyfrY=; b=kR7rlnNGB8Lq4TwSxlRUaKSnbuERjbyVXfh3tivi9bYjPgzTgqDv1xmwUqTQhkUCog /Sxqphh4UGYojxTsEim/adgHO1ZABSLqdce7tx7J+Kn+RTMLFIqVk0Z9lnd5sJQ7rb47 Y3tlufhFhplHnUOLgb2b/d8toEqtuD1hoZ2dOVzlr9DVsSfSeLNkl1H+XMaNf2qGcfzK i8Av8fxyt6G8XobEPRRGmLKLX5KzaQK82TZa1125JID9PfNx3LRFbXQUkzVbjsvs9EIk 8H/WOZ25RW+Kqh2A66KYNd86DMZimCIFNsXNSl+RlIMtG2b01P/BEmrfDzkVlhJtx6l/ ty2g== X-Gm-Message-State: AOUpUlH558i80V+tlG8mpd19H8XedwFg1rCsUavh9rZxi2zf01wULzMB jcDBeowTru00Rg/DbX0iyOJwRJexPy8= X-Google-Smtp-Source: AA+uWPx3qad+U1jAOMbQ6J8cIj/HxHl+sLUrIT8laq1SzEcJeKYjiKWTjPUKB7ts/5C4jKELr5x1OQ== X-Received: by 2002:a17:902:864b:: with SMTP id y11-v6mr57032233plt.335.1534986100682; Wed, 22 Aug 2018 18:01:40 -0700 (PDT) Received: from localhost ([2620:15c:2c4:201:c7f9:6225:a527:f3a4]) by smtp.gmail.com with ESMTPSA id w69-v6sm5612239pgd.37.2018.08.22.18.01.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 22 Aug 2018 18:01:39 -0700 (PDT) From: Mahesh Bandewar To: Stephen Hemminger Cc: netdev , Mahesh Bandewar Subject: [PATCHv3 iproute2 2/2] iproute: make clang happy Date: Wed, 22 Aug 2018 18:01:37 -0700 Message-Id: <20180823010137.147932-1-mahesh@bandewar.net> X-Mailer: git-send-email 2.19.0.rc0.228.g281dcd1b4d0-goog MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Mahesh Bandewar These are primarily fixes for "string is not string literal" warnings / errors (with -Werror -Wformat-nonliteral). This should be a no-op change. I had to replace couple of print helper functions with the code they call as it was becoming harder to eliminate these warnings, however these helpers were used only at couple of places, so no major change as such. Signed-off-by: Mahesh Bandewar --- include/json_writer.h | 3 +-- ip/iplink_can.c | 19 ++++++++++++------- lib/color.c | 1 + lib/json_print.c | 1 + lib/json_writer.c | 15 +-------------- misc/ss.c | 3 ++- tc/m_ematch.c | 1 + tc/m_ematch.h | 1 + 8 files changed, 20 insertions(+), 24 deletions(-) diff --git a/include/json_writer.h b/include/json_writer.h index 9ab88e1dbdd9..0c8831c1136d 100644 --- a/include/json_writer.h +++ b/include/json_writer.h @@ -29,6 +29,7 @@ void jsonw_pretty(json_writer_t *self, bool on); void jsonw_name(json_writer_t *self, const char *name); /* Add value */ +__attribute__((format(printf, 2, 3))) void jsonw_printf(json_writer_t *self, const char *fmt, ...); void jsonw_string(json_writer_t *self, const char *value); void jsonw_bool(json_writer_t *self, bool value); @@ -59,8 +60,6 @@ void jsonw_luint_field(json_writer_t *self, const char *prop, unsigned long int num); void jsonw_lluint_field(json_writer_t *self, const char *prop, unsigned long long int num); -void jsonw_float_field_fmt(json_writer_t *self, const char *prop, - const char *fmt, double val); /* Collections */ void jsonw_start_object(json_writer_t *self); diff --git a/ip/iplink_can.c b/ip/iplink_can.c index 587413da15c4..c0deeb1f1fcf 100644 --- a/ip/iplink_can.c +++ b/ip/iplink_can.c @@ -316,11 +316,14 @@ static void can_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) struct can_bittiming *bt = RTA_DATA(tb[IFLA_CAN_BITTIMING]); if (is_json_context()) { + json_writer_t *jw; + open_json_object("bittiming"); print_int(PRINT_ANY, "bitrate", NULL, bt->bitrate); - jsonw_float_field_fmt(get_json_writer(), - "sample_point", "%.3f", - (float) bt->sample_point / 1000.); + jw = get_json_writer(); + jsonw_name(jw, "sample_point"); + jsonw_printf(jw, "%.3f", + (float) bt->sample_point / 1000); print_int(PRINT_ANY, "tq", NULL, bt->tq); print_int(PRINT_ANY, "prop_seg", NULL, bt->prop_seg); print_int(PRINT_ANY, "phase_seg1", @@ -415,12 +418,14 @@ static void can_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[]) RTA_DATA(tb[IFLA_CAN_DATA_BITTIMING]); if (is_json_context()) { + json_writer_t *jw; + open_json_object("data_bittiming"); print_int(PRINT_JSON, "bitrate", NULL, dbt->bitrate); - jsonw_float_field_fmt(get_json_writer(), - "sample_point", - "%.3f", - (float) dbt->sample_point / 1000.); + jw = get_json_writer(); + jsonw_name(jw, "sample_point"); + jsonw_printf(jw, "%.3f", + (float) dbt->sample_point / 1000.); print_int(PRINT_JSON, "tq", NULL, dbt->tq); print_int(PRINT_JSON, "prop_seg", NULL, dbt->prop_seg); print_int(PRINT_JSON, "phase_seg1", diff --git a/lib/color.c b/lib/color.c index eaf69e74d673..e5406294dfc4 100644 --- a/lib/color.c +++ b/lib/color.c @@ -132,6 +132,7 @@ void set_color_palette(void) is_dark_bg = 1; } +__attribute__((format(printf, 3, 4))) int color_fprintf(FILE *fp, enum color_attr attr, const char *fmt, ...) { int ret = 0; diff --git a/lib/json_print.c b/lib/json_print.c index 5dc41bfabfd4..77902824a738 100644 --- a/lib/json_print.c +++ b/lib/json_print.c @@ -100,6 +100,7 @@ void close_json_array(enum output_type type, const char *str) * functions handling different types */ #define _PRINT_FUNC(type_name, type) \ + __attribute__((format(printf, 4, 0))) \ void print_color_##type_name(enum output_type t, \ enum color_attr color, \ const char *key, \ diff --git a/lib/json_writer.c b/lib/json_writer.c index aa9ce1c65e51..68890b34ee92 100644 --- a/lib/json_writer.c +++ b/lib/json_writer.c @@ -152,6 +152,7 @@ void jsonw_name(json_writer_t *self, const char *name) putc(' ', self->out); } +__attribute__((format(printf, 2, 3))) void jsonw_printf(json_writer_t *self, const char *fmt, ...) { va_list ap; @@ -205,11 +206,6 @@ void jsonw_null(json_writer_t *self) jsonw_printf(self, "null"); } -void jsonw_float_fmt(json_writer_t *self, const char *fmt, double num) -{ - jsonw_printf(self, fmt, num); -} - void jsonw_float(json_writer_t *self, double num) { jsonw_printf(self, "%g", num); @@ -274,15 +270,6 @@ void jsonw_float_field(json_writer_t *self, const char *prop, double val) jsonw_float(self, val); } -void jsonw_float_field_fmt(json_writer_t *self, - const char *prop, - const char *fmt, - double val) -{ - jsonw_name(self, prop); - jsonw_float_fmt(self, fmt, val); -} - void jsonw_uint_field(json_writer_t *self, const char *prop, unsigned int num) { jsonw_name(self, prop); diff --git a/misc/ss.c b/misc/ss.c index 41e7762bb61f..93b1baf5dc40 100644 --- a/misc/ss.c +++ b/misc/ss.c @@ -976,6 +976,7 @@ static int buf_update(int len) } /* Append content to buffer as part of the current field */ +__attribute__((format(printf, 1, 2))) static void out(const char *fmt, ...) { struct column *f = current_field; @@ -1093,7 +1094,7 @@ static void print_header(void) { while (!field_is_last(current_field)) { if (!current_field->disabled) - out(current_field->header); + out("%s", current_field->header); field_next(); } } diff --git a/tc/m_ematch.c b/tc/m_ematch.c index ace4b3dd738b..a524b520b276 100644 --- a/tc/m_ematch.c +++ b/tc/m_ematch.c @@ -277,6 +277,7 @@ static int flatten_tree(struct ematch *head, struct ematch *tree) return count; } +__attribute__((format(printf, 5, 6))) int em_parse_error(int err, struct bstr *args, struct bstr *carg, struct ematch_util *e, char *fmt, ...) { diff --git a/tc/m_ematch.h b/tc/m_ematch.h index ff02d7ac9112..356f2eded7fc 100644 --- a/tc/m_ematch.h +++ b/tc/m_ematch.h @@ -102,6 +102,7 @@ static inline int parse_layer(const struct bstr *b) return INT_MAX; } +__attribute__((format(printf, 5, 6))) int em_parse_error(int err, struct bstr *args, struct bstr *carg, struct ematch_util *, char *fmt, ...); int print_ematch(FILE *, const struct rtattr *);