From patchwork Wed Jul 10 23:58:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matheus Tavares X-Patchwork-Id: 11039103 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D54FC13B1 for ; Thu, 11 Jul 2019 00:00:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C548828A00 for ; Thu, 11 Jul 2019 00:00:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B91A728A09; Thu, 11 Jul 2019 00:00:03 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,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 5819328A00 for ; Thu, 11 Jul 2019 00:00:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727770AbfGKAAC (ORCPT ); Wed, 10 Jul 2019 20:00:02 -0400 Received: from mail-qt1-f193.google.com ([209.85.160.193]:41583 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727386AbfGKAAC (ORCPT ); Wed, 10 Jul 2019 20:00:02 -0400 Received: by mail-qt1-f193.google.com with SMTP id d17so4444366qtj.8 for ; Wed, 10 Jul 2019 17:00:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=usp-br.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=CqQHOlwlfENkwc05/cG9Y2S77go+PAKki+Y1xBT2URM=; b=RRWyFdCd2a82Hp4pLzXPS0wiDaKzGQOzgx16pqvmGkF9djkP50Ugxp8K5DnczETPsv hF4wfFUfYas7/MIK9ByZwdKoAJ+4zPwJMMTNa9Z1zbmxnEy721iCO06vjfM1nTvPt+g4 tbaA3iGeQUUDlrUgAH8wWK1tkeA+DV6aiJWtfIOOmmQH8mwrultXF99ca0KzNkaPBPrD Y4BdhKr2r0vQT9FuGjCpIY1zAGYQt2SiUE8BbCy6M45ekrMYzYtw2GY0l+mAbTtwIs1e QPh2D/VIGyL+L3gozJwDW4Z4XtdcYWGOQwTOKWMtOKjXV/wbWFdlL1NFcrra0PVexkPp XXtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=CqQHOlwlfENkwc05/cG9Y2S77go+PAKki+Y1xBT2URM=; b=KZpiVoFDGhnt9LEJViNQHhNTbwIjQTAJBIovPDTRnLfYX8rWUkWH3Pi3kYCtCB+SZ6 KQ6p5ASDEMkkJOZdZASG2VAp6QVj3Cnxz+lfsuoD5oxsMs1Ro7hLpVxspWCsPoj4Mb8Z mmgtiZWuRhQAxuQAt1+7/ljwCBkDDCq8WyYpUa0EY0eNNjMTfSx/Wr3gJSi/h4yZSg5p +HB4uCcauIxx6EBZTQa8/2yxEz66/ZNuLjaHUFOnGW9LPr8p5joa9kdr/5AciC9PB/6A xTBQfWu4TcNZ+5mSPIOiMlY1bAI7cqrAl845j9qP4GWcbaFWu1RivkVPxwAsQRSLZ8+Q XkKg== X-Gm-Message-State: APjAAAW2U1GLUxrmKJezDHvZAp6I6Aa6ckyun0POmlzeP4i4tHbd+r3J 89NHKK6dgPO8DVXFza1OB8YiTw== X-Google-Smtp-Source: APXvYqxNzC9TMZUDGLLFLK5RgAWz8v4oao5YRBO5+nKKJ10bhV3Z5Ko9S3lU47JuaZK7PMuq6iVetQ== X-Received: by 2002:ac8:2f43:: with SMTP id k3mr605431qta.179.1562803201116; Wed, 10 Jul 2019 17:00:01 -0700 (PDT) Received: from mango.spo.virtua.com.br ([2804:14c:81:942d::1]) by smtp.gmail.com with ESMTPSA id x8sm1714546qkl.27.2019.07.10.16.59.55 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 10 Jul 2019 17:00:00 -0700 (PDT) From: Matheus Tavares To: Junio C Hamano Cc: git@vger.kernel.org, Thomas Gummerer , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= , Christian Couder , =?utf-8?b?Tmd1eeG7hW4gVGg=?= =?utf-8?b?w6FpIE5n4buNYyBEdXk=?= , =?utf-8?q?SZEDER_G?= =?utf-8?q?=C3=A1bor?= , Olga Telezhnaya , Johannes Schindelin , kernel-usp@googlegroups.com, Michael Haggerty Subject: [GSoC][PATCH v8 04/10] dir-iterator: use warning_errno when possible Date: Wed, 10 Jul 2019 20:58:58 -0300 Message-Id: <0cc5f1f0b4ea7de4e0508316e861ace50f39de1f.1562801255.git.matheus.bernardino@usp.br> X-Mailer: git-send-email 2.22.0 In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Change warning(..., strerror(errno)) by warning_errno(...). This helps to unify warning display besides simplifying a bit the code. Also, improve warning messages by surrounding paths with quotation marks and using more meaningful statements. Signed-off-by: Matheus Tavares --- dir-iterator.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/dir-iterator.c b/dir-iterator.c index f2dcd82fde..0c8880868a 100644 --- a/dir-iterator.c +++ b/dir-iterator.c @@ -71,8 +71,8 @@ int dir_iterator_advance(struct dir_iterator *dir_iterator) level->dir = opendir(iter->base.path.buf); if (!level->dir && errno != ENOENT) { - warning("error opening directory %s: %s", - iter->base.path.buf, strerror(errno)); + warning_errno("error opening directory '%s'", + iter->base.path.buf); /* Popping the level is handled below */ } @@ -122,11 +122,11 @@ int dir_iterator_advance(struct dir_iterator *dir_iterator) if (!de) { /* This level is exhausted; pop up a level. */ if (errno) { - warning("error reading directory %s: %s", - iter->base.path.buf, strerror(errno)); + warning_errno("error reading directory '%s'", + iter->base.path.buf); } else if (closedir(level->dir)) - warning("error closing directory %s: %s", - iter->base.path.buf, strerror(errno)); + warning_errno("error closing directory '%s'", + iter->base.path.buf); level->dir = NULL; if (--iter->levels_nr == 0) @@ -140,9 +140,8 @@ int dir_iterator_advance(struct dir_iterator *dir_iterator) strbuf_addstr(&iter->base.path, de->d_name); if (lstat(iter->base.path.buf, &iter->base.st) < 0) { if (errno != ENOENT) - warning("error reading path '%s': %s", - iter->base.path.buf, - strerror(errno)); + warning_errno("failed to stat '%s'", + iter->base.path.buf); continue; } @@ -170,9 +169,11 @@ int dir_iterator_abort(struct dir_iterator *dir_iterator) &iter->levels[iter->levels_nr - 1]; if (level->dir && closedir(level->dir)) { + int saved_errno = errno; strbuf_setlen(&iter->base.path, level->prefix_len); - warning("error closing directory %s: %s", - iter->base.path.buf, strerror(errno)); + errno = saved_errno; + warning_errno("error closing directory '%s'", + iter->base.path.buf); } }