From patchwork Tue Jun 21 16:18:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phil Sutter X-Patchwork-Id: 638769 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3rYtSh3ywxz9sf9 for ; Wed, 22 Jun 2016 02:28:20 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752675AbcFUQ2C (ORCPT ); Tue, 21 Jun 2016 12:28:02 -0400 Received: from orbyte.nwl.cc ([151.80.46.58]:37745 "EHLO mail.nwl.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752413AbcFUQ1l (ORCPT ); Tue, 21 Jun 2016 12:27:41 -0400 Received: from mail.nwl.cc (orbyte.nwl.cc [127.0.0.1]) by mail.nwl.cc (Postfix) with ESMTP id 26EBD67997; Tue, 21 Jun 2016 18:18:53 +0200 (CEST) Received: from xsao (localhost [IPv6:::1]) by mail.nwl.cc (Postfix) with ESMTP id 083C767398; Tue, 21 Jun 2016 18:18:53 +0200 (CEST) From: Phil Sutter To: Stephen Hemminger Cc: Daniel Borkmann , David Ahern , Nicolas Dichtel , Julien Floret , netdev@vger.kernel.org Subject: [iproute PATCH v2 1/7] tc: m_action: Improve conversion to C99 style initializers Date: Tue, 21 Jun 2016 18:18:35 +0200 Message-Id: <1466525921-15738-2-git-send-email-phil@nwl.cc> X-Mailer: git-send-email 2.8.2 In-Reply-To: <1466525921-15738-1-git-send-email-phil@nwl.cc> References: <1466525921-15738-1-git-send-email-phil@nwl.cc> X-Virus-Scanned: ClamAV using ClamSMTP Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This improves my initial change in the following points: - Drop superfluous comma after last expression in block. - No need to initialize variables to zero as the key feature of C99 initializers is to do this implicitly. - By relocating the declaration of struct rtattr *tail, it can be initialized at the same time. Fixes: a0a73b298a579 ("tc: m_action: Use C99 style initializers for struct req") Signed-off-by: Phil Sutter --- tc/m_action.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/tc/m_action.c b/tc/m_action.c index ea16817aefd4f..ce399d2e43ccc 100644 --- a/tc/m_action.c +++ b/tc/m_action.c @@ -398,10 +398,9 @@ static int tc_action_gd(int cmd, unsigned int flags, int *argc_p, char ***argv_p .n = { .nlmsg_len = NLMSG_LENGTH(sizeof(struct tcamsg)), .nlmsg_flags = NLM_F_REQUEST | flags, - .nlmsg_type = cmd, + .nlmsg_type = cmd }, - .t.tca_family = AF_UNSPEC, - .buf = { 0 } + .t.tca_family = AF_UNSPEC }; argc -= 1; @@ -491,8 +490,6 @@ static int tc_action_modify(int cmd, unsigned int flags, int *argc_p, char ***ar int argc = *argc_p; char **argv = *argv_p; int ret = 0; - - struct rtattr *tail; struct { struct nlmsghdr n; struct tcamsg t; @@ -501,13 +498,12 @@ static int tc_action_modify(int cmd, unsigned int flags, int *argc_p, char ***ar .n = { .nlmsg_len = NLMSG_LENGTH(sizeof(struct tcamsg)), .nlmsg_flags = NLM_F_REQUEST | flags, - .nlmsg_type = cmd, + .nlmsg_type = cmd }, - .t.tca_family = AF_UNSPEC, - .buf = { 0 } + .t.tca_family = AF_UNSPEC }; + struct rtattr *tail = NLMSG_TAIL(&req.n); - tail = NLMSG_TAIL(&req.n); argc -= 1; argv += 1; if (parse_action(&argc, &argv, TCA_ACT_TAB, &req.n)) { @@ -539,8 +535,7 @@ static int tc_act_list_or_flush(int argc, char **argv, int event) char buf[MAX_MSG]; } req = { .n.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcamsg)), - .t.tca_family = AF_UNSPEC, - .buf = { 0 } + .t.tca_family = AF_UNSPEC }; tail = NLMSG_TAIL(&req.n);