From patchwork Thu Jul 27 07:12:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 1813795 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=m0x0dUQx; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RBY9t4v8dz1yYc for ; Fri, 28 Jul 2023 00:31:46 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E065186860; Thu, 27 Jul 2023 16:30:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="m0x0dUQx"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 90D8486795; Thu, 27 Jul 2023 09:13:05 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id CF09B8627C for ; Thu, 27 Jul 2023 09:13:02 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=dan.carpenter@linaro.org Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-31758eb5db8so647897f8f.2 for ; Thu, 27 Jul 2023 00:13:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1690441982; x=1691046782; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=QSx3MzJuweW/CHlCe/et0j6XLIsKnAaOtr/XlinxsF0=; b=m0x0dUQxekuKpCaNV5Hme4C9IvyPPpj9DVq5vw8lmUOI4JK15CMRB19b6MNsq2TK2v HI0mJAFAn3B4z27cnNalFaqidJYvNKYVbjQZ2rpEaNJu0eO841MB4bVVAmJMce72NUor n2DKeN8m1EnyOtq6jSdV6qVCoOzKvsZn+RZupGD6PD2i1JZXZqtgGyeyvuErjRyN/3nm 2R6Uif3FQRMpeTb+7eCUxOK6cdKlrR2uuu64K5tlxzaIz2Qd7HlPpfxWqGd/ggItBcUi TLiJd+l8FQ2bnXUFCA2kyeKBoT5GBqvMxYHi+yKIIwd6lxgx7Al9N8YiBy1JZGSu7yRJ GmqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690441982; x=1691046782; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=QSx3MzJuweW/CHlCe/et0j6XLIsKnAaOtr/XlinxsF0=; b=AjNkSbniqLg+IQfrcx0D+wELhGE8y0sWl2jg0mD/Lh0ydHckySK52iir/aDtsojnro 2dc6hCzq0PieZzoRMOllqlGRNOaKv9U7SGmCuPnGGCZsXDBWlgI9iGAxeu4aasuRdJtW TCIC26R6SjF6NlrB97Sjnkb3L9DubUVinmDvUnlTG4M35CrcuSBGihyRXyPEoBtlkRQf ipqQjz7Lk1p543zametotPovZMNWF18cfla1N3OJfkbt3sDy4k5vJYWX2d8eGndwUOqt C+oghBiqW1BLQK2DnhsCA+MWwZkFAJsRlxK+wM1qTHNw8+3xP+A4Kzr9PrRPHXWEN7lq F/Yg== X-Gm-Message-State: ABy/qLZtFuaTnRd+qD1V9+77zWcIXl108sPKcdLr6H4Zdotf7nGnOdyS dCe5fdlKewrKsI70U1PXS5fTg/xG3yGQMXgBAss= X-Google-Smtp-Source: APBJJlGU2TWLrGVeUbQGl/ysUdagwblj+5C8k+aWno6uDQpxgh4mhSYQNwKI+8q10chLMC9bhBAs8w== X-Received: by 2002:a5d:58fc:0:b0:317:5b3b:89a1 with SMTP id f28-20020a5d58fc000000b003175b3b89a1mr1141447wrd.10.1690441982243; Thu, 27 Jul 2023 00:13:02 -0700 (PDT) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id t6-20020a5d6906000000b0031760af2331sm1060906wru.100.2023.07.27.00.13.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jul 2023 00:13:02 -0700 (PDT) Date: Thu, 27 Jul 2023 10:12:58 +0300 From: Dan Carpenter To: Heinrich Schuchardt , Masahisa Kojima Cc: Ilias Apalodimas , u-boot@lists.denx.de Subject: [PATCH] test: unicode: fix a sizeof() vs ARRAY_SIZE() bug Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding X-Mailman-Approved-At: Thu, 27 Jul 2023 16:29:59 +0200 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The u16_strlcat() is in units of u16 not bytes. So the limit needs to be ARRAY_SIZE() instead of sizeof(). Signed-off-by: Dan Carpenter --- test/unicode_ut.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/unicode_ut.c b/test/unicode_ut.c index b27d7116b9ee..62ff5d10bf94 100644 --- a/test/unicode_ut.c +++ b/test/unicode_ut.c @@ -807,12 +807,12 @@ static int unicode_test_u16_strlcat(struct unit_test_state *uts) /* dest and src are empty string */ memset(buf, 0, sizeof(buf)); - ret = u16_strlcat(buf, &null_src, sizeof(buf)); + ret = u16_strlcat(buf, &null_src, ARRAY_SIZE(buf)); ut_asserteq(1, ret); /* dest is empty string */ memset(buf, 0, sizeof(buf)); - ret = u16_strlcat(buf, src, sizeof(buf)); + ret = u16_strlcat(buf, src, ARRAY_SIZE(buf)); ut_asserteq(5, ret); ut_assert(!unicode_test_u16_strcmp(buf, src, 40)); @@ -820,7 +820,7 @@ static int unicode_test_u16_strlcat(struct unit_test_state *uts) memset(buf, 0xCD, (sizeof(buf) - sizeof(u16))); buf[39] = 0; memcpy(buf, dest, sizeof(dest)); - ret = u16_strlcat(buf, &null_src, sizeof(buf)); + ret = u16_strlcat(buf, &null_src, ARRAY_SIZE(buf)); ut_asserteq(6, ret); ut_assert(!unicode_test_u16_strcmp(buf, dest, 40));