mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-07-06 14:32:03 +00:00
lib: Always set errno in hcreate_r
This could give a confusing error message if it failed and didn't set errno. Signed-off-by: Sean Anderson <seanga2@gmail.com> Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
This commit is contained in:
parent
038b13ee81
commit
60ffcf218f
1 changed files with 6 additions and 2 deletions
|
@ -110,8 +110,10 @@ int hcreate_r(size_t nel, struct hsearch_data *htab)
|
|||
}
|
||||
|
||||
/* There is still another table active. Return with error. */
|
||||
if (htab->table != NULL)
|
||||
if (htab->table != NULL) {
|
||||
__set_errno(EINVAL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Change nel to the first prime number not smaller as nel. */
|
||||
nel |= 1; /* make odd */
|
||||
|
@ -124,8 +126,10 @@ int hcreate_r(size_t nel, struct hsearch_data *htab)
|
|||
/* allocate memory and zero out */
|
||||
htab->table = (struct env_entry_node *)calloc(htab->size + 1,
|
||||
sizeof(struct env_entry_node));
|
||||
if (htab->table == NULL)
|
||||
if (htab->table == NULL) {
|
||||
__set_errno(ENOMEM);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* everything went alright */
|
||||
return 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue