diff mbox series

[V2,04/10] Cleanup: drop sdup fuction

Message ID 20241030163957.2822282-5-stefano.babic@swupdate.org
State Accepted
Headers show
Series Introduce BTRFS Snapshot Handler | expand

Commit Message

Stefano Babic Oct. 30, 2024, 4:39 p.m. UTC
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 <stefano.babic@swupdate.org>
---
 core/swupdate.c | 4 ++--
 core/util.c     | 8 --------
 include/util.h  | 1 -
 3 files changed, 2 insertions(+), 11 deletions(-)

--
2.34.1
diff mbox series

Patch

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);

 /*