Modules xsize and idx

2021-04-07 Thread Marc Nieper-Wißkirchen
What is the relationship between these two modules? Both try to minimize subtle bugs due to overflow. However, both approaches cannot be easily combined as xsize expects unsigned integers while idx is a signed one. What is the suggested use of these modules for new code? Thanks, Marc

Re: Modules xsize and idx

2021-04-07 Thread Bruno Haible
Hi Marc, > What is the relationship between these two modules? Both try to minimize > subtle bugs due to overflow. These two modules, and the wraparound/overflow checking macros of 'intprops' [1], are attempts to catch integer overflow. The three approaches differ in terms of coding effort and p

Re: Modules xsize and idx

2021-04-07 Thread Marc Nieper-Wißkirchen
Hi Bruno, thanks for replying so quickly. Let's assume I have a procedure void *foo_create (size_t n) { void *foo = malloc (a + n * b); if (foo == NULL) ...; ... return foo; } I want 'foo_create' to handle possible overflows. To me, it seems that should use the xsize module for this and

Re: replacement for 'join'?

2021-04-07 Thread Bernhard Voelker
On 4/6/21 10:45 PM, Bruno Haible wrote: > For small data, I would have transformed the first file to a 'sed' > script, that I would then apply to the second file. But HP-UX 'sed' > has a limit of 100 -e expressions per invocation. I don't have access to HP-UX (and there's none in the GCC compile f

Re: replacement for 'join'?

2021-04-07 Thread Bruno Haible
Bernhard Voelker wrote: > but doesn't HP-UX' sed support the POSIX -f option there? Probably it does. But then the replacement script would have to create a temporary file. Which is about 30 lines of shell code. Bruno

Re: Modules xsize and idx

2021-04-07 Thread Paul Eggert
On 4/7/21 4:00 AM, Marc Nieper-Wißkirchen wrote: That's why I am wondering whether it makes sense to have an xsize module that uses idx_t instead of size_t. It might, yes. I use intprops.h for this sort of thing, but perhaps a stripped-down header would be appropriate. I am planning to make

Re: xalloc.h use idx_t

2021-04-07 Thread Bruno Haible
Hi Paul, > I am planning to make xalloc.h use idx_t rather than size_t for object > and byte counts, as we really should be using signed integers there, for > all the usual reasons. I agree that using idx_t in more places helps reduce overflow problem. However, since 'xalloc' started out as "m

Re: xalloc.h use idx_t

2021-04-07 Thread Marc Nieper-Wißkirchen
xalloc is now called with a size_t argument. If the argument type is silently changed to an idx_t, existing code which calls the new xalloc still with a size_t argument will trigger a compiler warning under GCC's -Wsign-conversion. Fixing existing code isn't easy because the sizeof operator return

Re: [PATCH] tests: fix test-execute with GNU make jobserver

2021-04-07 Thread Bruno Haible
Hi Dmitry, Thanks for the proposed patch. > On POSIX systems the GNU make jobserver is implemented as a pipe, > and these two unexpected descriptors make test-execute-child fail. This problem description is a bit technical. It took me a bit of work to translate your description into a "how to re

Re: [PATCH] tests: fix test-execute with GNU make jobserver

2021-04-07 Thread Dmitry V. Levin
Hi Bruno, On Wed, Apr 07, 2021 at 11:30:47PM +0200, Bruno Haible wrote: > Hi Dmitry, > > Thanks for the proposed patch. > > > On POSIX systems the GNU make jobserver is implemented as a pipe, > > and these two unexpected descriptors make test-execute-child fail. > > This problem description is

Re: [PATCH] tests: fix test-execute with GNU make jobserver

2021-04-07 Thread Bruno Haible
Hi Dmitry, > Yes, it is reliable as it mirrors > for (fd = 0; fd < 20; fd++) > piece of code in tests/test-execute-child.c file. Ah, I had missed that. Thanks. > there could > be other external sources of inherited descriptors, so the test should > rather be robust and make sure these exte

Re: [PATCH] tests: fix test-execute with GNU make jobserver

2021-04-07 Thread Dmitry V. Levin
On Thu, Apr 08, 2021 at 01:44:35AM +0200, Bruno Haible wrote: [...] > I'm applying this fix: > > > 2021-04-07 Bruno Haible > > execute tests: Avoid test failure in certain environments. > Reported by Dmitry V. Levin in >

[PATCH] utimens: fix confusing arg type in internal func

2021-04-07 Thread Paul Eggert
Although the old code was technically correct, this was accidental and it understandably confused Coverity. Reported by Ondrej Dubaj in: https://lists.gnu.org/r/bug-tar/2021-04/msg0.html * lib/utimens.c (update_timespec): Change arg type from ‘struct timespec *[2]’ (pointer to array of 2 point