groff
[Top][All Lists]
Advanced

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

Re: Use `strsave()`, not `strdup()`.


From: Ralph Corderoy
Subject: Re: Use `strsave()`, not `strdup()`.
Date: Tue, 09 Nov 2021 14:29:26 +0000

Hi Ingo,

> Actually, just exit(1) is better than abort().  The abort() facility
> is intended for catching violations of invariants (i.e., catching
> bugs).

abort(3)'s only intention is to terminate the program abnormally with
dumping core by default to aid investigation.  When to do that is
subjective.

> It should not be called for normal runtime failures.

I agree estrdup() finding strdup(3) fails is exit(1), whilst being
passed a NULL pointer, against strdup()'s contract, is abort().

> Then again, changing from pure malloc(3) to xmalloc() also requires
> proceeding carefully and not blindly by script because there might be
> rare instances of malloc(3) calls where handling failure and *not*
> exiting the program right away could be functionally important.

I only do it automatically if I can eyeball all cases to know they
should all be converted.  Otherwise, I set up a couple of keys in
vim(1): the first moves through all the files I'm editing to the next
occurrence, the second makes the change and then also moves to the next
match, writing the file if needed.  Then a first pass can whizz through
all cases, changing the easy ones to eyeball, and a second pass
typically has far fewer cases to read more carefully.  My two fingers
become ‘Yes: change it’ and ‘Skip’.

> True in general, but not an issue in this case: the groff codebase
> does not call strdup(3) right now.

Ah, sorry, just going by the emails and not the source code, I didn't
pick up on that.

> So if Branden proceeds as he plans

Let's go, Branden!

-- 
Cheers, Ralph.



reply via email to

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