From mboxrd@z Thu Jan 1 00:00:00 1970 From: Cyril Hrubis Date: Mon, 9 Aug 2021 15:24:22 +0200 Subject: [LTP] [PATCH] lib/tst_tmpdir: tst_get_tmpdir() add error handing In-Reply-To: References: <20210806032131.25721-1-zhanglianjie@uniontech.com> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: ltp@lists.linux.it Hi! > > - return strdup(TESTDIR); > > + ret = strdup(TESTDIR); > Is a failing strdup here really a thing? The only reason strdup should > be able to fail is with ENOMEM. > The only way tst_brkm will work, if strdup fails here is, if TESTDIR is > an extremely huge string (the NULL case is already handled above). It's unlikely, but it may happen if: * Someone runs memeater on the baground along with LTP * And kernel is set not to overcommit And in a case of the test lirary I would rather see it written so that we check everything, even the unlikely errors. -- Cyril Hrubis chrubis@suse.cz