From 719cacb92e039308e23cbd6b653275e939a5aca5 Mon Sep 17 00:00:00 2001 From: Rasmus Villemoes Date: Tue, 21 Apr 2026 09:54:32 +0200 Subject: stdio: drop stdio_clone 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 Signed-off-by: Rasmus Villemoes --- common/stdio.c | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'common/stdio.c') 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); -- cgit v1.3.1