[PATCH 04/10] Cleanup: drop sdup fuction

6 views
Skip to first unread message

Stefano Babic

unread,
Oct 30, 2024, 6:15:58 AM10/30/24
to swup...@googlegroups.com, Stefano Babic
This has the same implementation of strdup(), and it makes no sense to
have it. Drop it and switch back to strdup.

Signed-off-by: Stefano Babic <stefan...@swupdate.org>
---
core/swupdate.c | 4 ++--
core/util.c | 8 --------
include/util.h | 1 -
3 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/core/swupdate.c b/core/swupdate.c
index 4b98add9..d59df204 100644
--- a/core/swupdate.c
+++ b/core/swupdate.c
@@ -530,7 +530,7 @@ int main(int argc, char **argv)
char *root;
int bootdev;
case 'f':
- cfgfname = sdup(optarg);
+ cfgfname = strdup(optarg);
break;
case 'g':
root = get_root_device();
@@ -570,7 +570,7 @@ int main(int argc, char **argv)
if (cfgfname == NULL) {
struct stat stbuf;
if (stat(CONFIG_DEFAULT_CONFIG_FILE, &stbuf) == 0) {
- cfgfname = sdup(CONFIG_DEFAULT_CONFIG_FILE);
+ cfgfname = strdup(CONFIG_DEFAULT_CONFIG_FILE);
}
}

diff --git a/core/util.c b/core/util.c
index 1e50d948..d50176fc 100644
--- a/core/util.c
+++ b/core/util.c
@@ -59,14 +59,6 @@ static struct decryption_key *aes_key = NULL;

static char *fwenv_config = NULL;

-char *sdup(const char *str) {
- char *p;
- if ((p = (char *) malloc(strlen(str) + 1)) != NULL) {
- strcpy(p, str);
- }
- return p;
-}
-
static char* TMPDIR = NULL;
static char* TMPDIRSCRIPT = NULL;

diff --git a/include/util.h b/include/util.h
index 1ac108be..dcfbd4f0 100644
--- a/include/util.h
+++ b/include/util.h
@@ -211,7 +211,6 @@ bool is_hex_str(const char *ascii);
#define max_t(type,x,y) \
({ type __x = (x); type __y = (y); __x > __y ? __x: __y; })

-char *sdup(const char *str);
bool strtobool(const char *s);

/*
--
2.34.1

Reply all
Reply to author
Forward
0 new messages