bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Preliminary patch for flock (just for discussion)


From: Jim Meyering
Subject: Re: Preliminary patch for flock (just for discussion)
Date: Fri, 03 Oct 2008 09:47:34 +0200

"Richard W.M. Jones" <address@hidden> wrote:
> I have to go off and do something else this afternoon, but here is a
> preliminary patch for flock support for Windows.  It compiles with my
> MinGW cross-compiler but I haven't really tested it properly yet.
>
> As you can see, it introduces another header file replacement - for
> <sys/file.h>  On Linux this file just contains flock and its associated
> definitions.  On MinGW the file is empty except for an include of
> <fcntl.h>.

Hi Rich,

That looks fine, modulo some formatting,
so it'd be good to filter .c and .h files through GNU indent.

The do_unlock function would be a little nicer like this:
(syntax-change only)

    static int
    do_unlock (HANDLE h)
    {
      DWORD size_lower, size_upper;
      int res = file_size (h, &size_lower, &size_upper);
      if (!res)
        return 0;
      return UnlockFile (h, 0, 0, size_lower, size_upper);
    }

In flock itself, you should detect when two or more of the
LOCK_{SH,EX,UN} bits are set, and handle that like any other EINVAL.
Currently, it silently accepts the invalid "operation", and performs
whichever it encounters first in the if/else tests.  Using a switch
would be a little cleaner.

BTW, considering rand is used only for w95, I think it's
fine to use here.  However, I wonder if it's even worthwhile
to keep w95-specific code in gnulib.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]