All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] lib/tst_tmpdir: tst_get_tmpdir() add error handing
@ 2021-08-06  3:21 zhanglianjie
  2021-08-06  4:40 ` Joerg Vehlow
  2021-08-09 13:29 ` Cyril Hrubis
  0 siblings, 2 replies; 5+ messages in thread
From: zhanglianjie @ 2021-08-06  3:21 UTC (permalink / raw)
  To: ltp

Signed-off-by: zhanglianjie <zhanglianjie@uniontech.com>

diff --git a/lib/tst_tmpdir.c b/lib/tst_tmpdir.c
index 0c39eb89f..f006e4893 100644
--- a/lib/tst_tmpdir.c
+++ b/lib/tst_tmpdir.c
@@ -108,12 +108,18 @@ int tst_tmpdir_created(void)

 char *tst_get_tmpdir(void)
 {
+	char *ret = NULL;
+
 	if (TESTDIR == NULL) {
 		tst_brkm(TBROK, NULL, "you must call tst_tmpdir() first");
 		return NULL;
 	}

-	return strdup(TESTDIR);
+	ret = strdup(TESTDIR);
+	if (!ret)
+		tst_brkm(TBROK, NULL, "strdup() failed");
+
+	return ret;
 }

 const char *tst_get_startwd(void)
--
2.20.1




^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-08-09 13:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-06  3:21 [LTP] [PATCH] lib/tst_tmpdir: tst_get_tmpdir() add error handing zhanglianjie
2021-08-06  4:40 ` Joerg Vehlow
2021-08-06  5:42   ` zhanglianjie
2021-08-09 13:24   ` Cyril Hrubis
2021-08-09 13:29 ` Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.