From patchwork Mon Dec 25 22:55:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 852884 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MDA8NU2z"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="T0K7KhfT"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3z5DxD4cQcz9ryv for ; Tue, 26 Dec 2017 09:56:00 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BPvrQKjCPrySYfEwlPZRO5gBmNDkYXd7LrwtvDzC5UI=; b=MDA8NU2zcyz5eU CitKoDcgMSJP/TfBlWfxymehrkJ7GMj8Gv0LhAkql5tt2iKfiQzzWWhJc4HdNkVR7BQ8HC5NbmJK9 ssFz+o2PBzxa6z6EDpTIiRLIJScjdNEprrS4J7B/obYhfAhOifF+dOuxazyKquTrNpqyAjuuY8m/d V/gQBhRIMQDyOxtNz0pNBynuqNAtPL7hwE3uYlINdpj2m2jHQPmwj67ZxCTzWOzoE38cDa9p/5TmH dI0Vr38O/dVwfyY0w87c3NwZgQg8x1VneCsXuyMYVpRzwHy4WmjHWOtIO6jG+Z4+ZMg8Ml2s6s4/q EDlLF6anqTwjP1TZaLsQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eTbev-0007eh-HJ; Mon, 25 Dec 2017 22:55:49 +0000 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eTbec-0007TN-8t for lede-dev@lists.infradead.org; Mon, 25 Dec 2017 22:55:31 +0000 Received: by mail-pl0-x241.google.com with SMTP id g2so17060464pli.8 for ; Mon, 25 Dec 2017 14:55:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Duzg4MqfbSsp2tTA1mWTdwa3yDdkgnHzNGyziNtDCD8=; b=T0K7KhfTakyOY2EwsAXNJM0gywTwfwrMFJukyYpnweSO8hx9zNbOkJaoMvt2wsZkT6 kNQfzShPybHXoun+j6AB34y+3a4picCfL6mRSSQX/mUvhm0GR+k5PgiLc2cssS3FXOGS J9iDz9JKlR9T8PI+xbSSRVFSHAtb2stt1B5cctUr2dN8mpBZiRR+7pC3K0135atSOGW/ jcBdBgTMc9cxnwlpC0Gi7toS+GEC+7kGz1A1/U6OVKoaXB3025rEGPVhFVOtWCsmr0+7 +xNVE9Qz4N0Z75FRK0OxwDCaLE0+xqIrm/9hFzT81bOZFNMd7hHQnjgGvbxN5hpZ6kUb 9g9A== 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:in-reply-to :references; bh=Duzg4MqfbSsp2tTA1mWTdwa3yDdkgnHzNGyziNtDCD8=; b=SUol4EmFOPCn9t7GQjzi/XztFuCT9U5VGZTKeERC2EN2qHlyDoQ2K+ncPuPn3Mf6+q kpW7TYYh3sxtnrOfKR1Py8E5ZSi142Y+LzpH1CjsfmwVhLyZJev/RI1zeiMNwsa3ln/G 6myxA77/tepleEDpKg/q+10HIg7pliFXQhr9TX3f0Ag2+iy7oTFoJcz+eRFdhKjQS8IT WC/k2K6VTEeTX9Tmgf/5sHCq7MB1OLTBRX6IujVIZFY310tpgXEkOgMH9gs/UtF1xlTC VQOtr0a7k7AWouAbzy5OyHygL1Yyht4BbetN1tdn01Q//Y7jNe4sWLIB4UvD/KoWN/g9 UlmQ== X-Gm-Message-State: AKGB3mLvAlgw/pXDPAgx7zy8RhRBdSpsj6wlPfAdE71Bd1m3Tshtg8f+ StdC7AHcPqCI8cEQkg8OLVYYg5Ae X-Google-Smtp-Source: ACJfBotAJZHjv+PSsS0ZenWgBQChKwBNFssEOSCLhR5FGZ8k9FQfbiq47phWz35dUHz8STwkW41oHg== X-Received: by 10.84.234.198 with SMTP id i6mr22962918plt.159.1514242519431; Mon, 25 Dec 2017 14:55:19 -0800 (PST) Received: from DESKTOP-CEH0M93.lan ([2001:470:1f05:c3e:98da:65ff:24e5:ee50]) by smtp.gmail.com with ESMTPSA id y5sm59432556pfd.63.2017.12.25.14.55.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 25 Dec 2017 14:55:18 -0800 (PST) From: Rosen Penev To: lede-dev@lists.infradead.org Date: Mon, 25 Dec 2017 14:55:24 -0800 Message-Id: <1514242524-4319-2-git-send-email-rosenp@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514242524-4319-1-git-send-email-rosenp@gmail.com> References: <1514242524-4319-1-git-send-email-rosenp@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171225_145530_313950_BA707617 X-CRM114-Status: UNSURE ( 8.87 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2607:f8b0:400e:c01:0:0:0:241 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (rosenp[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain Subject: [LEDE-DEV] [PATCH 2/2] firewall3: Fix errors reported by cppcheck. X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rosen Penev MIME-Version: 1.0 Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Mainly sign conversion errors with printf function (%d vs. %u). Exact command line used was: cppcheck --enable=all --inconclusive --force . 2> err.txt && cat err.txt | grep -v never | grep -v reduced Only errors that I felt comfortable with were fixed. Signed-off-by: Rosen Penev --- defaults.c | 2 +- ipsets.c | 2 +- iptables.c | 11 ++++++----- options.c | 2 +- ubus.c | 4 ++-- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/defaults.c b/defaults.c index f1be1dd..41c41a4 100644 --- a/defaults.c +++ b/defaults.c @@ -331,7 +331,7 @@ set_default(const char *name, int set) return; } - fprintf(f, "%u\n", set); + fprintf(f, "%d\n", set); fclose(f); } diff --git a/ipsets.c b/ipsets.c index 30c6463..9ce89aa 100644 --- a/ipsets.c +++ b/ipsets.c @@ -321,7 +321,7 @@ fw3_load_ipsets(struct fw3_state *state, struct uci_package *p, static void create_ipset(struct fw3_ipset *ipset, struct fw3_state *state) { - bool first = true; + bool first; struct fw3_ipset_datatype *type; diff --git a/iptables.c b/iptables.c index d848239..70bfa59 100644 --- a/iptables.c +++ b/iptables.c @@ -929,11 +929,12 @@ void fw3_ipt_rule_mac(struct fw3_ipt_rule *r, struct fw3_mac *mac) { char buf[sizeof("ff:ff:ff:ff:ff:ff\0")]; - uint8_t *addr = mac->mac.ether_addr_octet; + uint8_t *addr; if (!mac) return; + addr = mac->mac.ether_addr_octet; sprintf(buf, "%02x:%02x:%02x:%02x:%02x:%02x", addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); @@ -981,12 +982,12 @@ fw3_ipt_rule_limit(struct fw3_ipt_rule *r, struct fw3_limit *limit) fw3_ipt_rule_addarg(r, false, "-m", "limit"); - sprintf(buf, "%u/%s", limit->rate, fw3_limit_units[limit->unit]); + sprintf(buf, "%d/%s", limit->rate, fw3_limit_units[limit->unit]); fw3_ipt_rule_addarg(r, limit->invert, "--limit", buf); if (limit->burst > 0) { - sprintf(buf, "%u", limit->burst); + sprintf(buf, "%d", limit->burst); fw3_ipt_rule_addarg(r, limit->invert, "--limit-burst", buf); } } @@ -1089,7 +1090,7 @@ fw3_ipt_rule_time(struct fw3_ipt_rule *r, struct fw3_time *time) if (p > buf) *p++ = ','; - p += sprintf(p, "%u", i); + p += sprintf(p, "%d", i); } } @@ -1105,7 +1106,7 @@ fw3_ipt_rule_time(struct fw3_ipt_rule *r, struct fw3_time *time) if (p > buf) *p++ = ','; - p += sprintf(p, "%u", i); + p += sprintf(p, "%d", i); } } diff --git a/options.c b/options.c index f686cf0..8b2a8fd 100644 --- a/options.c +++ b/options.c @@ -1145,7 +1145,7 @@ fw3_address_to_string(struct fw3_address *address, bool allow_invert, bool as_ci } else { - p += sprintf(p, "/%u", fw3_netmask2bitlen(address->family, + p += sprintf(p, "/%d", fw3_netmask2bitlen(address->family, &address->mask.v6)); } diff --git a/ubus.c b/ubus.c index 5bb4f5d..1c823f1 100644 --- a/ubus.c +++ b/ubus.c @@ -260,10 +260,10 @@ static void fw3_ubus_rules_add(struct blob_buf *b, const char *service, } if (instance) - snprintf(comment, sizeof(comment), "ubus:%s[%s] %s %d", + snprintf(comment, sizeof(comment), "ubus:%s[%s] %s %u", service, instance, type ? type : "rule", n); else - snprintf(comment, sizeof(comment), "ubus:%s %s %d", + snprintf(comment, sizeof(comment), "ubus:%s %s %u", service, type ? type : "rule", n); blobmsg_add_string(b, "name", comment);