summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2017-09-27 12:22:59 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2017-09-27 14:02:20 +0200
commit9710d39e0de75ca5fd5a5d9c6de4fe4efba31790 (patch)
tree79644c473123dd7193e2ea7a8520869f907b3a37 /common
parentdc8c2c4b942f499fedb284b096eff3b2b9970b9c (diff)
downloadbarebox-9710d39e0de75ca5fd5a5d9c6de4fe4efba31790.tar.gz
barebox-9710d39e0de75ca5fd5a5d9c6de4fe4efba31790.tar.xz
file_list: Allow only unique names on list
The key to a file_list is it's name, so ensure it's unique. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/file-list.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/common/file-list.c b/common/file-list.c
index 0b760c1aec..e13d5af659 100644
--- a/common/file-list.c
+++ b/common/file-list.c
@@ -23,7 +23,13 @@ struct file_list_entry *file_list_entry_by_name(struct file_list *files, const c
int file_list_add_entry(struct file_list *files, const char *name, const char *filename,
unsigned long flags)
{
- struct file_list_entry *entry = xzalloc(sizeof(*entry));
+ struct file_list_entry *entry;
+
+ entry = file_list_entry_by_name(files, name);
+ if (entry)
+ return -EEXIST;
+
+ entry = xzalloc(sizeof(*entry));
entry->name = xstrdup(name);
entry->filename = xstrdup(filename);