Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 24 Nov 2016 11:34:12 -0800
From:      Conrad Meyer <cem@freebsd.org>
To:        =?UTF-8?Q?Dag=2DErling_Sm=C3=B8rgrav?= <des@freebsd.org>
Cc:        src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org,  svn-src-head@freebsd.org
Subject:   Re: svn commit: r309109 - head/lib/libutil
Message-ID:  <CAG6CVpVBrvKjv%2BRJZxG3n_zuxPtxeyEA86ov=YSQUh_GXWd3VQ@mail.gmail.com>
In-Reply-To: <201611241450.uAOEoLA5079215@repo.freebsd.org>
References:  <201611241450.uAOEoLA5079215@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
This kind of language isn't really appropriate.  Please revert the
commit immediately.

When you've had time to think of an appropriate way to word comments
to the same effect, please commit that separately.

Thanks,
Conrad

On Thu, Nov 24, 2016 at 6:50 AM, Dag-Erling Sm=C3=B8rgrav <des@freebsd.org>=
 wrote:
> Author: des
> Date: Thu Nov 24 14:50:21 2016
> New Revision: 309109
> URL: https://svnweb.freebsd.org/changeset/base/309109
>
> Log:
>   Add a warning against modifying this code without understanding it, and
>   an example of how not to make it more portable.  I've had this lying
>   around uncommitted since 2009...
>
> Modified:
>   head/lib/libutil/flopen.c
>
> Modified: head/lib/libutil/flopen.c
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D
> --- head/lib/libutil/flopen.c   Thu Nov 24 14:48:46 2016        (r309108)
> +++ head/lib/libutil/flopen.c   Thu Nov 24 14:50:21 2016        (r309109)
> @@ -1,5 +1,5 @@
>  /*-
> - * Copyright (c) 2007 Dag-Erling Co=C3=AFdan Sm=C3=B8rgrav
> + * Copyright (c) 2007-2009 Dag-Erling Co=C3=AFdan Sm=C3=B8rgrav
>   * All rights reserved.
>   *
>   * Redistribution and use in source and binary forms, with or without
> @@ -37,6 +37,14 @@ __FBSDID("$FreeBSD$");
>
>  #include <libutil.h>
>
> +/*
> + * Reliably open and lock a file.
> + *
> + * DO NOT, UNDER PAIN OF DEATH, modify this code without first reading t=
he
> + * revision history and discussing your changes with <des@freebsd.org>.
> + * Don't be fooled by the code's apparent simplicity; there would be no
> + * need for this function if it was as easy to get right as you think.
> + */
>  int
>  flopen(const char *path, int flags, ...)
>  {
> @@ -100,6 +108,14 @@ flopen(const char *path, int flags, ...)
>                         errno =3D serrno;
>                         return (-1);
>                 }
> +#ifdef DONT_EVEN_THINK_ABOUT_IT
> +               if (fcntl(fd, F_SETFD, FD_CLOEXEC) !=3D 0) {
> +                       serrno =3D errno;
> +                       (void)close(fd);
> +                       errno =3D serrno;
> +                       return (-1);
> +               }
> +#endif
>                 return (fd);
>         }
>  }
>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAG6CVpVBrvKjv%2BRJZxG3n_zuxPtxeyEA86ov=YSQUh_GXWd3VQ>