devicetree-compiler.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Pierre-Clément Tosi" <ptosi-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
To: David Gibson <david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org>
Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	"Mostafa Saleh"
	<smostafa-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>,
	"Pierre-Clément Tosi"
	<ptosi-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Subject: [PATCH] libfdt: Fix fdt_appendprop_addrrange documentation
Date: Thu, 31 Aug 2023 13:39:18 +0100	[thread overview]
Message-ID: <20230831123918.rf54emwkzgtcb7aw@google.com> (raw)

According to the documentation, the function should default to the very
common property name <reg> when none is "specified". However, neither
passing NULL (ends up calling strlen(NULL) and segfaults) nor ""
(appends a property with an empty name) implements this behavior.

Furthermore, the test case supposed to cover this default value actually
passes the value to the function, somewhat defeating its own purpose:

    /* 2. default property name */

    // ...

    err = fdt_appendprop_addrrange(fdt, 0, offset, "reg", addr, size);
    if (err)
            FAIL("Failed to set \"reg\": %s", fdt_strerror(err));
    check_getprop_addrrange(fdt, 0, offset, "reg", 1);

Finally, nothing in the implementation of the function seems to attempt
to cover that use-case.

As the feature can't ever have been used by clients and as the resulting
reduced readability of the caller seems (IMO) to outweigh any potential
benefit this API would bring, remove the erroneous documentation instead
of trying to fix the function.

Reported-by: Mostafa Saleh <smostafa-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Pierre-Clément Tosi <ptosi-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
---
 libfdt/libfdt.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libfdt/libfdt.h b/libfdt/libfdt.h
index 2a4f32c..0677fea 100644
--- a/libfdt/libfdt.h
+++ b/libfdt/libfdt.h
@@ -2029,7 +2029,7 @@ static inline int fdt_appendprop_cell(void *fdt, int nodeoffset,
  * address and size) to the value of the named property in the given
  * node, or creates a new property with that value if it does not
  * already exist.
- * If "name" is not specified, a default "reg" is used.
+ *
  * Cell sizes are determined by parent's #address-cells and #size-cells.
  *
  * This function may insert data into the blob, and will therefore
-- 
2.42.0.rc2.253.gd59a3bf2b4-goog


-- 
Pierre

             reply	other threads:[~2023-08-31 12:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-31 12:39 Pierre-Clément Tosi [this message]
     [not found] ` <20230831123918.rf54emwkzgtcb7aw-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org>
2023-09-04  5:31   ` [PATCH] libfdt: Fix fdt_appendprop_addrrange documentation David Gibson

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=20230831123918.rf54emwkzgtcb7aw@google.com \
    --to=ptosi-hpiqsd4aklfqt0dzr+alfa@public.gmane.org \
    --cc=david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+@public.gmane.org \
    --cc=devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=smostafa-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).