From patchwork Thu Nov 30 17:31:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ari Sundholm X-Patchwork-Id: 10085401 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A524E60234 for ; Thu, 30 Nov 2017 17:34:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F5802A1FB for ; Thu, 30 Nov 2017 17:34:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 841A92A1FD; Thu, 30 Nov 2017 17:34:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1FD902A1FB for ; Thu, 30 Nov 2017 17:34:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753719AbdK3ReE (ORCPT ); Thu, 30 Nov 2017 12:34:04 -0500 Received: from mx1.mpynet.fi ([82.197.21.84]:38062 "EHLO mx1.mpynet.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753717AbdK3ReC (ORCPT ); Thu, 30 Nov 2017 12:34:02 -0500 From: Ari Sundholm To: CC: Ari Sundholm Subject: [PATCH 2/2] fsstress: getcwd() return value fixes Date: Thu, 30 Nov 2017 19:31:24 +0200 Message-ID: <1512063084-12105-2-git-send-email-ari@tuxera.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512063084-12105-1-git-send-email-ari@tuxera.com> References: <1512063084-12105-1-git-send-email-ari@tuxera.com> MIME-Version: 1.0 X-ClientProxiedBy: tuxera-exch.ad.tuxera.com (10.20.48.11) To tuxera-exch.ad.tuxera.com (10.20.48.11) Received-SPF: none Sender: fstests-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a check for the return value of getcwd(). Fix another check which mistakenly checks if the return value is less than zero instead of checking whether the return value is NULL. Signed-off-by: Ari Sundholm --- ltp/fsstress.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ltp/fsstress.c b/ltp/fsstress.c index 13d5dd5..028c232 100644 --- a/ltp/fsstress.c +++ b/ltp/fsstress.c @@ -495,7 +495,7 @@ int main(int argc, char **argv) (void)mkdir(dirname, 0777); if (logname && logname[0] != '/') { - if (getcwd(rpath, sizeof(rpath)) < 0){ + if (!getcwd(rpath, sizeof(rpath))){ perror("getcwd failed"); exit(1); } @@ -970,6 +970,10 @@ doproc(void) } top_ino = statbuf.st_ino; homedir = getcwd(NULL, 0); + if (!homedir) { + perror("getcwd failed"); + _exit(1); + } seed += procid; srandom(seed); if (namerand)