Re: [PATCH] Add checks for new and tmp directories to mx_is_maildir()

Alejandro Colomar via Mutt-dev <[email protected]>
Newsgroups gmane.mail.mutt.devel
Message-ID <qyot6xmzbrgplr2slmb5k4ktg6f4l3zkz677euguz56alxmw4b@szyjhrcger7r>
Hi,

On Fri, Feb 06, 2026 at 03:39:22PM +0100, Gero Treuner wrote:
> Hi all,
> 
> On Fri, Feb 06, 2026 at 02:37:36PM +0100, Alejandro Colomar via Mutt-dev wrote:
> > > > However, I personally argue for code clarity except when optimization is
> > > > called for.  In this case, I don't think it's worth the trade off.  See just
> > > > below the function in mh.c, mx_is_mh(), for similar code, also called by
> > > > mx_get_magic().
> > > > 
> > > > As always, if others disagree please just say so.
> > > 
> > > personally I see it the same way, considering readability and simplicity
> > > a big priority; parsing the proposed version is (at least for me) much
> > > harder than the original version.
> > 
> > +1
> > 
> > Except that maybe with fstatat(2) (as Crystal said) it could be readable
> > --we'd have to see the code, though--.
> > 
> > readability >>> optimizations
> 
> Thank you and others for the feedback.
> 
> A quick research shows that fstatat(2) isn't a good option:
> 
> 1) Even on Linux it was introduced no earlier than with glibc 2.4, so
>    this makes a case for portability fiddling with automake etc.
> 
> 2) The directory needs to be opened with a file descriptor, which adds
>    resource handling.
>    I don't see consistency of the directory in the event that by
>    mounting etc. the file system changes as a benefit here. IMO it is
>    fine to fail for a test of a mail folder when something looks fishy.
>    (Otherwise the test could succeed for a place which isn't available
>    any more.)
> 
> But the same gain of readability could probably be achieved by other
> means. (Let's see when I'll come back to puzzling ...)

If we can't have fstatat(2), I honsetly prefer the inefficient version.
I'd be surprised to change my mind on that.


Cheers,
Alex

> 
> 
> Kind regards,
>    Gero

-- 
<https://www.alejandro-colomar.es>
Use port 80 (that is, <...:80/>).
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEES7Jt9u9GbmlWADAi64mZXMKQwqkFAmmGBRoACgkQ64mZXMKQ
wqkXWQ//RUiaCAvDKXICNUZxUdsvXSD2HhRbi8eZDs/tZHTa9j8VgJpIFc0eP/N0
DB2lkvIWTplTp0C0fAAHqmZcGvZ33Yt7FbCKl4fbdtkDswbHOKNVEBf93AxCrfa3
cB4cPxUKtd6n3f67svddkaMxOSA9lRMgMOwj0ZewAjYqUdbuZRfSvyPFxAnZ2soe
/NY5EeXoYU8rxZBS2FUwqrPF5kdCwMMSvCnpxGfxGlGJeGxjoezzHHQ0pg5CqRHp
z9CycNtB5m/KtBjF5phtB7BCVWL0a1p8Zk8lYYx8xbwQDFuEMkvoH8h6crLinI8e
bsLUIvgboRlzTzdkCfCP4nDYkRLuqUihIkmt1PZj4oKLstvq1ZsBr1uQcUYkDkdq
7/bZ4wP1Th6ea2FO9r45PxOkkm0MPnpBq1JE9Y1HGQ+KVbIEly+GMzbavg2Yetcr
zqueEJqqLWU6KjbMwkJzJf1vWzKUj1yG7eX7miPuvw1mxaxB/mqj0hpC5nSixqUA
fQ4zpWRtcEKtKJpZNrFUpdzv5CbZNuNTW38MiJGJAdnoKjQXuIYG3yKn9FlF93fU
kaDB0kQbkaxdAuxgLM09anNb0aBZHOBYRzkZeFraddl0Z2N14uA0S1gpebAKvq1f
BJTj96kQAxEfQAVbkADuAKDWK5RUztn31iAaiJ6cGqPuX+GNTq8=
=8fRI
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.