[PATCH 2/8] stdio: drop stdio_clone
Rasmus Villemoes
ravi at prevas.dk
Sun Apr 12 21:59:41 CEST 2026
The helper stdio_clone only has a single caller, so it certainly
doesn't need to be public. But in fact, it is merely an open-coded
memdup() - which for some reason uses calloc() even if the whole
allocation is obviously immediately overwritten.
Drop it and just use memdup() directly.
Signed-off-by: Rasmus Villemoes <ravi at prevas.dk>
---
common/stdio.c | 18 +-----------------
include/stdio_dev.h | 1 -
2 files changed, 1 insertion(+), 18 deletions(-)
diff --git a/common/stdio.c b/common/stdio.c
index fc965944209..038e576147b 100644
--- a/common/stdio.c
+++ b/common/stdio.c
@@ -217,27 +217,11 @@ struct stdio_dev *stdio_get_by_name(const char *name)
return NULL;
}
-struct stdio_dev *stdio_clone(struct stdio_dev *dev)
-{
- struct stdio_dev *_dev;
-
- if (!dev)
- return NULL;
-
- _dev = calloc(1, sizeof(struct stdio_dev));
- if (!_dev)
- return NULL;
-
- memcpy(_dev, dev, sizeof(struct stdio_dev));
-
- return _dev;
-}
-
int stdio_register_dev(struct stdio_dev *dev, struct stdio_dev **devp)
{
struct stdio_dev *_dev;
- _dev = stdio_clone(dev);
+ _dev = memdup(dev, sizeof(*dev));
if (!_dev)
return -ENODEV;
list_add_tail(&_dev->list, &devs.list);
diff --git a/include/stdio_dev.h b/include/stdio_dev.h
index f7f9c10199e..d93604331ff 100644
--- a/include/stdio_dev.h
+++ b/include/stdio_dev.h
@@ -96,7 +96,6 @@ int stdio_add_devices(void);
int stdio_deregister_dev(struct stdio_dev *dev, int force);
struct list_head *stdio_get_list(void);
struct stdio_dev *stdio_get_by_name(const char *name);
-struct stdio_dev *stdio_clone(struct stdio_dev *dev);
int drv_lcd_init(void);
int drv_video_init(void);
--
2.53.0
More information about the U-Boot
mailing list