Message ID | 20240509223213.97389-2-newtwen+github@gmail.com |
---|---|
State | New |
Headers | show
Return-Path: <openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=cp0o8lV2; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=desiato.20200630 header.b=Bt+yvC65; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=iv1Wo39d; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Vb6KN0ldyz20fh for <incoming@patchwork.ozlabs.org>; Fri, 10 May 2024 08:35:20 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=CAk1ZXHUURh3mfcVlEZfm7kqA1Bwt31NGjj5ATd3oho=; b=cp0o8lV2SmmbcW bhOcYhBzB+NmeDgjEiAoZfUipOEHFcWjRn5AeZjiSfF1ppOs4HaT1j399TxdgZB7OMGU/pBrvAmIf CsCZItG5fuWZUo9X6SH01TmLsz2bbyOakZ2x/nhPOLl1dQ/r4zStGPzGwh7SOVhyapQ6rpUu8elY+ 7fJY2Qbw6qvX91QEXMnBc++giT7FEhUTTqwlO+xlZ4NlPB5p7epAP+pWbMyn74Md3APvvHEmi5dOn tD06uV7r8vkjL8Ru2uYgLe7jf9edYyTBGhkN0tBF8RJ0GDqTqFvqlQPHk7ek+vYlXa8RCscJ9PSbv 7wWBgQw+De+EFskeBqcg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s5CK2-000000037BZ-2Ras; Thu, 09 May 2024 22:33:06 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s5CJX-000000036uJ-3eGh for openwrt-devel@bombadil.infradead.org; Thu, 09 May 2024 22:32:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc: Content-Type:Content-ID:Content-Description; bh=1851bva9I3Ea2O0o5M9rBH6ihz6ynT0wg8vx05ZmHb4=; b=Bt+yvC65NbobXbwOFjfNeIw8FG a+9BnJIe0p/kh5CbGOHLHQzy27IaQqEpJ+G1ri8Du6wJ8fFpHcCJ9Z3GVVZyQ58RQlUX7WT2FnB99 +2Bg7ncFNVUuf/jlfHC+5lV+hn6E/qFy8ibcgGqNq8VtVNtX+58yjuk1JST4pCU6MNwQ7dywE4Njv IHsZ8PLBkwhsj6KdgpMeLp8FsL07xn8rMHLtzbMAb8dV8RT469BHMKyhQe9xWaCx4uakb+hvkUxDi sc97ItWOHml44eTLW2GejIDgBlkaCp8EnfmjZeDJt9FXXJHS2SdQp26n2REATV56Gq0lQqf3ACPUI 7Pge2vxA==; Received: from mail-lj1-f172.google.com ([209.85.208.172]) by desiato.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s5CJP-000000034Fl-0jCF for openwrt-devel@lists.openwrt.org; Thu, 09 May 2024 22:32:33 +0000 Received: by mail-lj1-f172.google.com with SMTP id 38308e7fff4ca-2e3f6166e4aso24605861fa.1 for <openwrt-devel@lists.openwrt.org>; Thu, 09 May 2024 15:32:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715293936; x=1715898736; darn=lists.openwrt.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=1851bva9I3Ea2O0o5M9rBH6ihz6ynT0wg8vx05ZmHb4=; b=iv1Wo39dAwF2upIaDydyng5ndTNPCjdIZKti7izXfE6yuONiEMhK6xJsPEYqwbGyMc 6Ki8bb8rxIse5/MVthvR4fVBMVaAE3ndFvqLIwI9MPsreYIUyJHNpBCoj7pC6NGHEn8I bDcSy1MT/qI3rwJefeXBlBmQWSJIgOuGzzYFycIZUG+13tu7XrKoa7KSaT1YmKGB4BC2 hDpQCwc5tTIHkaL/I/F+VO/wHQw0Mnh+hrqOCbqr4i3JE7WxnDd1aujmiZCJrhYpuRls RMYU8Cxs9YVAT+Q6jZ/leiuZ1EBQdzehGaeAMs/gbgcVauZlExOoh3+a+Re4tvJ4Vput XxQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715293936; x=1715898736; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:sender:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=1851bva9I3Ea2O0o5M9rBH6ihz6ynT0wg8vx05ZmHb4=; b=muyQWlwhHTs3E9fwdJeEx6poG+6VK/l/5/CKOCZJpShdGPjTdyreHAdSONBBwisMw4 NTeNm+uLt7IL4gRpJRXaOciiUYYikWXCY5YlnsKVfU799g0hL/Hn+a/AmrOHZRLFI1FZ G/6HA2m0e1Bt9ctvJKIyF8qtgO95R2bP2TOxL8iwWzav12/6RSd7La6fqkEjP+xT9a/1 uAE6loWRQYDRemxcWSEaY3+uEZQP+Xv6La42Dv6U8QEpTMQG1NSb2g1XqngIboo4b862 C/9SSrKDoOlKAstpK+OwuwPj22P3TQfq2+41T2ghXSBkTidRwi9+thnCOQse+OEHiRgV NnIg== X-Gm-Message-State: AOJu0YxPEIgAWRno/BqSEuyRubHElcW5Co4Qif0xpr0yYeF7zAui2uOc l1Aj+jAn/cn3ulA3oHmxOpKB+jv0jUyihdHzjLkRA34K85WW9poeRaHcUg== X-Google-Smtp-Source: AGHT+IHQFpZHNgjpoB8ClxYpVLvrVeEHxHdVvtDy0Iag7sb3ExITvgHBEq6T/aklkJkjoOd3O/B3tA== X-Received: by 2002:a2e:808e:0:b0:2da:7cd1:3f1f with SMTP id 38308e7fff4ca-2e52039e2b7mr4742411fa.52.1715293935522; Thu, 09 May 2024 15:32:15 -0700 (PDT) Received: from blackhol3 ([2001:9b0:40::cae3:cb03]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2e4d0bbc3a6sm3156191fa.13.2024.05.09.15.32.15 for <openwrt-devel@lists.openwrt.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 15:32:15 -0700 (PDT) From: Paul Donald <newtwen+github@gmail.com> To: OpenWrt Development List <openwrt-devel@lists.openwrt.org> Subject: [RFC PATCH 01/14] config: refactor parse_leasetime() - branch amount remains same Date: Fri, 10 May 2024 00:30:33 +0200 Message-ID: <20240509223213.97389-2-newtwen+github@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240509223213.97389-1-newtwen+github@gmail.com> References: <20240509223213.97389-1-newtwen+github@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240509_233228_980439_250B5DC7 X-CRM114-Status: GOOD ( 10.40 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "desiato.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Paul Donald Also make 's' value a noop. Signed-off-by: Paul Donald --- src/config.c | 20 ++++++++ 1 file changed, 8 insertions(+), 12 deletions(-) Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.208.172 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [newtwen+github(at)gmail.com] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.208.172 listed in list.dnswl.org] X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List <openwrt-devel.lists.openwrt.org> List-Unsubscribe: <https://lists.openwrt.org/mailman/options/openwrt-devel>, <mailto:openwrt-devel-request@lists.openwrt.org?subject=unsubscribe> List-Archive: <http://lists.openwrt.org/pipermail/openwrt-devel/> List-Post: <mailto:openwrt-devel@lists.openwrt.org> List-Help: <mailto:openwrt-devel-request@lists.openwrt.org?subject=help> List-Subscribe: <https://lists.openwrt.org/mailman/listinfo/openwrt-devel>, <mailto:openwrt-devel-request@lists.openwrt.org?subject=subscribe> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "openwrt-devel" <openwrt-devel-bounces@lists.openwrt.org> Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org |
Series |
odhcpd config value clamping
|
expand
|
diff --git a/src/config.c b/src/config.c index 62d4857..346d74a 100644 --- a/src/config.c +++ b/src/config.c @@ -356,18 +356,14 @@ static double parse_leasetime(struct blob_attr *c) { double time = strcmp(val, "infinite") ? strtod(val, &endptr) : UINT32_MAX; if (time && endptr && endptr[0]) { - if (endptr[0] == 's') - time *= 1; - else if (endptr[0] == 'm') - time *= 60; - else if (endptr[0] == 'h') - time *= 3600; - else if (endptr[0] == 'd') - time *= 24 * 3600; - else if (endptr[0] == 'w') - time *= 7 * 24 * 3600; - else - goto err; + switch(endptr[0]) { + case 's': break; + case 'm': time *= 60; break; + case 'h': time *= 3600; break; + case 'd': time *= 24 * 3600; break; + case 'w': time *= 7 * 24 * 3600; break; + default: goto err; + } } if (time < 60)