From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 6/7] getenv_f() env variable exist w/o needing a buffer
Date: Fri, 04 Jan 2013 23:06:56 +0100 [thread overview]
Message-ID: <20130104220656.EE90B202B9B@gemini.denx.de> (raw)
In-Reply-To: <1357323245-12455-6-git-send-email-yorksun@freescale.com>
Dear York Sun,
In message <1357323245-12455-6-git-send-email-yorksun@freescale.com> you wrote:
> From: James Yang <James.Yang@freescale.com>
>
> getenv_f() searches the environment for a variable name and copies the
> value of the variable to a buffer pointed to by one of the function's
> parameters. However, this means that the buffer needs to exist and
> needs to be of sufficient length (passed as another parameter to
> getenv_f()) to hold the requested variable's value, even if all that is
> desired is the mere detection of the existence of the variable itself.
>
> This patch removes the requirement that the buffer needs to exist. If
> the pointer to the buffer is set to NULL and the requested variable is
Hm... this adds a special case and as such increases complexity - and
what is the benefit for you?
In your code, you use this feature exactly once, which means all you
save is a single buffer on the stack of a function that does not
appear to be critical in terms of stack size.
> /*
> * Look up variable from environment for restricted C runtime env.
> + * If the variable is found, return the number of bytes copied.
> + * If buf is NULL, len is ignored, and, if the variable is found, return 1.
> + * If the variable is not found, return -1.
I think your description is not quite correct, and I dislike the
inconsistent behaviour we get though your patch. So far, this
function returns the length of the variable value, or -1 in case of
errors. This should not change even if we implement the suggested
feature, i. e. even when passing NULL as buffer pointer the function
should still return the length, and not some unrelated result.
> + /* found */
> + if (!buf)
> + return 1;
I tend to NAK this part.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"One lawyer can steal more than a hundred men with guns."
- The Godfather
next prev parent reply other threads:[~2013-01-04 22:06 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-04 18:13 [U-Boot] [PATCH 1/7] powerpc/mpc8xxx: Enable entering DDR debugging by key press York Sun
2013-01-04 18:14 ` [U-Boot] [PATCH 2/7] Move DDR command parsing to separate function York Sun
2013-01-04 18:14 ` [U-Boot] [PATCH 3/7] Fix data stage name matching issue York Sun
2013-01-04 18:14 ` [U-Boot] [PATCH 4/7] Add copy command to FSL DDR interactive York Sun
2013-01-04 18:14 ` [U-Boot] [PATCH 5/7] README.fsl-ddr typos and update to reflect hotkey York Sun
2013-01-04 18:14 ` [U-Boot] [PATCH 6/7] getenv_f() env variable exist w/o needing a buffer York Sun
2013-01-04 22:06 ` Wolfgang Denk [this message]
2013-01-04 23:08 ` James Yang
2013-01-05 6:23 ` Wolfgang Denk
2013-01-07 17:46 ` [U-Boot] [u-boot-release] " Timur Tabi
2013-01-04 18:14 ` [U-Boot] [PATCH 7/7] powerpc/mpc8xxx: FSL DDR debugger auto run of stored commands York Sun
2013-01-08 6:35 ` [U-Boot] [PATCH 1/7] powerpc/mpc8xxx: Enable entering DDR debugging by key press Wolfgang Denk
2013-01-08 6:39 ` sun york-R58495
2013-01-08 19:24 ` York Sun
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=20130104220656.EE90B202B9B@gemini.denx.de \
--to=wd@denx.de \
--cc=u-boot@lists.denx.de \
/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