From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 3B9A1431FCF for ; Thu, 24 May 2012 13:57:22 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ejjTXKX1pPOU for ; Thu, 24 May 2012 13:57:21 -0700 (PDT) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com [209.85.217.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 78064431FBD for ; Thu, 24 May 2012 13:57:21 -0700 (PDT) Received: by lbbgk8 with SMTP id gk8so179779lbb.26 for ; Thu, 24 May 2012 13:57:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:subject:in-reply-to:references:user-agent:date:message-id :mime-version:content-type:x-gm-message-state; bh=coa1rnBnz553nybF0VZC4Z++LLTJzrA4mctnfpAOhvY=; b=iP5g75GceqWRRE65gVmtwZyhc+rGzM0w5F/gh/r0rNPLlOe8fR82Lntrzl/K9VVIxx gitSe1tQr1zvbyr/P3mUYX6qPvWEQ85gvufkIwLLgC46RDbK8zCl3yZHfSarTGYLW0HG lZpR08dvSN6hWaXgrMIwC23RIIbFwaGfMMNks2/n7L4zJ2FBBNaXBxxwTFkFiPIs6ucN R1PeVzTeKIZxK3ALugpxeW8rVU+gTkDQwFLcpv/L5mAnaVG1jx0g0nhzpK4ItWAwjhA/ kK2mAlwj5+sLXMWDnYjTd0vBVJF6OUAkje+3L7JIdfIswoJujtUI8LHC1OPCReyrG0DG VYWA== Received: by 10.112.99.98 with SMTP id ep2mr404637lbb.45.1337893039587; Thu, 24 May 2012 13:57:19 -0700 (PDT) Received: from localhost (dsl-hkibrasgw4-fe50dc00-68.dhcp.inet.fi. [80.220.80.68]) by mx.google.com with ESMTPS id fd1sm1879774lbb.7.2012.05.24.13.57.17 (version=SSLv3 cipher=OTHER); Thu, 24 May 2012 13:57:18 -0700 (PDT) From: Jani Nikula To: Austin Clements , notmuch@notmuchmail.org Subject: Re: [PATCH v3 3/4] new: Merge error checks from add_files and add_files_recursive In-Reply-To: <1337887922-13163-4-git-send-email-amdragon@mit.edu> References: <1336429240-1114-1-git-send-email-amdragon@mit.edu> <1337887922-13163-1-git-send-email-amdragon@mit.edu> <1337887922-13163-4-git-send-email-amdragon@mit.edu> User-Agent: Notmuch/0.13+13~gc259b9a (http://notmuchmail.org) Emacs/23.3.1 (i686-pc-linux-gnu) Date: Thu, 24 May 2012 23:57:16 +0300 Message-ID: <87wr415mc3.fsf@nikula.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Gm-Message-State: ALoCoQmMf+pGKz66oBofHHM2arg6LZTf7eT8hL6ybHQhY+4v0CJUQGKVaNhOhQhOtf6io8XtID1+ X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 24 May 2012 20:57:22 -0000 On Thu, 24 May 2012, Austin Clements wrote: > Before XXX, add_files_recursive could have been called on a symlink to > a non-directory. Hence, calling it on a non-directory was not an > error, so a separate function, add_files, existed to fail loudly in > situations where the path had to be a directory. "Before XXX"? Otherwise, this 3/4 and following 4/4 patch LGTM. I didn't bother looking at 1/4 and 2/4 again, as you say there were no changes. BR, Jani. > > With the new stat-ing logic, add_files_recursive is always called on > directories, so the separation of this logic is no longer necessary. > Hence, this patch moves the strict error checking previously done by > add_files into add_files_recursive. > --- > notmuch-new.c | 27 +++++---------------------- > 1 file changed, 5 insertions(+), 22 deletions(-) > > diff --git a/notmuch-new.c b/notmuch-new.c > index c64f1a7..2b05605 100644 > --- a/notmuch-new.c > +++ b/notmuch-new.c > @@ -308,11 +308,10 @@ add_files_recursive (notmuch_database_t *notmuch, > } > stat_time = time (NULL); > > - /* This is not an error since we may have recursed based on a > - * symlink to a regular file, not a directory, and we don't know > - * that until this stat. */ > - if (! S_ISDIR (st.st_mode)) > - return NOTMUCH_STATUS_SUCCESS; > + if (! S_ISDIR (st.st_mode)) { > + fprintf (stderr, "Error: %s is not a directory.\n", path); > + return NOTMUCH_STATUS_FILE_ERROR; > + } > > fs_mtime = st.st_mtime; > > @@ -655,23 +654,7 @@ add_files (notmuch_database_t *notmuch, > const char *path, > add_files_state_t *state) > { > - notmuch_status_t status; > - struct stat st; > - > - if (stat (path, &st)) { > - fprintf (stderr, "Error reading directory %s: %s\n", > - path, strerror (errno)); > - return NOTMUCH_STATUS_FILE_ERROR; > - } > - > - if (! S_ISDIR (st.st_mode)) { > - fprintf (stderr, "Error: %s is not a directory.\n", path); > - return NOTMUCH_STATUS_FILE_ERROR; > - } > - > - status = add_files_recursive (notmuch, path, state); > - > - return status; > + return add_files_recursive (notmuch, path, state); > } > > /* XXX: This should be merged with the add_files function since it > -- > 1.7.10 > > _______________________________________________ > notmuch mailing list > notmuch@notmuchmail.org > http://notmuchmail.org/mailman/listinfo/notmuch