]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
stdio: drop stdio_clone
authorRasmus Villemoes <ravi@prevas.dk>
Tue, 21 Apr 2026 07:54:32 +0000 (09:54 +0200)
committerTom Rini <trini@konsulko.com>
Tue, 12 May 2026 21:38:00 +0000 (15:38 -0600)
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.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Rasmus Villemoes <ravi@prevas.dk>
common/stdio.c
include/stdio_dev.h

index fc9659442098165981ed7a4bb0cfbae00e7d1a2d..038e576147b67ce321ce9f54dcbdd6d4eea97160 100644 (file)
@@ -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);
index f7f9c10199eeeb55ff69fb14adfa35a5bd42282f..d93604331ff5c686f2bd6c2ec09af5706771a866 100644 (file)
@@ -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);