[U-Boot] [PATCH 06/11] env: Allow env_attr_walk to pass a priv * to callback
Simon Glass
sjg at chromium.org
Fri Apr 24 06:34:07 CEST 2015
On 21 April 2015 at 16:20, Joe Hershberger <joe.hershberger at gmail.com> wrote:
> Hi All,
>
> On Tue, Apr 21, 2015 at 5:02 PM, Joe Hershberger <joe.hershberger at ni.com> wrote:
>> In some cases it can be helpful to have context in the callback about
>> the calling situation. This is needed for following patches.
>>
>> Signed-off-by: Joe Hershberger <joe.hershberger at ni.com>
>> ---
>
> 8<--snip-->8
>
>> diff --git a/common/env_attr.c b/common/env_attr.c
>> index d266142..f0bf504 100644
>> --- a/common/env_attr.c
>> +++ b/common/env_attr.c
>> @@ -26,7 +26,8 @@
>> * list = entry[,list]
>> */
>> int env_attr_walk(const char *attr_list,
>> - int (*callback)(const char *name, const char *attributes))
>> + int (*callback)(const char *name, const char *attributes, void *priv),
>> + void *priv)
>> {
>> const char *entry, *entry_end;
>> char *name, *attributes;
>> @@ -93,7 +94,7 @@ int env_attr_walk(const char *attr_list,
>> if (strlen(name) != 0) {
>> int retval = 0;
>>
>> - retval = callback(name, attributes);
>> + retval = callback(name, attributes, priv);
>> if (retval) {
>> free(entry_cpy);
>> return retval;
>> @@ -120,8 +121,11 @@ static int reverse_name_search(const char *searched, const char *search_for,
>> if (result)
>> *result = NULL;
>>
>> - if (*search_for == '\0')
>> - return (char *)searched;
>> + if (*search_for == '\0') {
>> + if (result)
>> + *result = searched;
>> + return strlen(searched);
>> + }
>
> I noticed shortly after sending this that this hunk belongs in the
> previous patch.
>
>>
>> for (;;) {
>> const char *match = strstr(cur_searched, search_for);
>> @@ -153,7 +157,8 @@ static int reverse_name_search(const char *searched, const char *search_for,
>> *nextch != '\0')
>> continue;
>>
>> - *result = match;
>> + if (result)
>> + *result = match;
>
> As does this hunk.
>
>> result_size = strlen(search_for);
>> }
>>
>
> 8<--snip-->8
>
> My apologies... I'll resend after any other comments. Please do not
> apply as is, Tom.
>
> Thanks,
> -Joe
Reviewed-by: Simon Glass <sjg at chromium.org>
More information about the U-Boot
mailing list