mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Josh Law <joshlaw48@gmail.com>
To: shuvampandey1@gmail.com
Cc: James.Bottomley@HansenPartnership.com, akpm@linux-foundation.org,
	andy@kernel.org, kees@kernel.org,
	linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] lib/tests: add string_get_size() boundary tests
Date: Tue, 21 Apr 2026 21:32:06 +0100	[thread overview]
Message-ID: <AA9B2A7E-A88D-457C-8244-50087631B347@gmail.com> (raw)
In-Reply-To: <177680283372.84187.11707577520741615468@gmail.com>

Hi Shuvam!

I see that there already is discussion going on around patches
like this (from your Link: fields)

So I am going to try and keep this
as low drama as possible 

Okay, the one thing I will say about this, is I particularly like
these tests. They are very very smart and "gnarly" :-)

Like for example, 

+	/* binary values stay in bytes until the 1 KiB boundary */
+	test_string_get_size_one(1000, 1, "1.00 kB", "1000 B");
+	test_string_get_size_one(1018, 1, "1.02 kB", "1018 B");
+	test_string_get_size_one(1023, 1, "1.02 kB", "1023 B");
+	test_string_get_size_one(1024, 1, "1.02 kB", "1.00 KiB");
+	test_string_get_size_one(1025, 1, "1.03 kB", "1.00 KiB");

That is a INCREDIBLY smart edge case.  (I probably wouldn't think of this)

Or even

+	/* binary rounding around 1000 KiB */
+	test_string_get_size_one(1023487, 1, "1.02 MB", "999 KiB");
+	test_string_get_size_one(1023488, 1, "1.02 MB", "1000 KiB");
+	test_string_get_size_one(1024000, 1, "1.02 MB", "1000 KiB");
+	test_string_get_size_one(1024511, 1, "1.02 MB", "1000 KiB");
+	test_string_get_size_one(1024512, 1, "1.02 MB", "1001 KiB");

Again, smart. I like these tests.


So, you (more) than deserve these tags, as I tested it too :) :

Reviewed-by: Josh Law <joshlaw48@gmail.com>
Tested-by: Josh Law <joshlaw48@gmail.com>

  reply	other threads:[~2026-04-21 20:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-21 20:19 Shuvam Pandey
2026-04-21 20:32 ` Josh Law [this message]
2026-04-22  7:32 ` Andy Shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=AA9B2A7E-A88D-457C-8244-50087631B347@gmail.com \
    --to=joshlaw48@gmail.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=akpm@linux-foundation.org \
    --cc=andy@kernel.org \
    --cc=kees@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shuvampandey1@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®