[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(
From: |
Laurent Vivier |
Subject: |
Re: [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE) |
Date: |
Mon, 19 Sep 2016 11:46:01 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.1 |
On 16/09/2016 17:45, Peter Maydell wrote:
> On 16 September 2016 at 16:39, Daniel P. Berrange <address@hidden> wrote:
>> On Fri, Sep 16, 2016 at 03:47:37PM +0100, Peter Maydell wrote:
>>> On 16 September 2016 at 14:55, Laurent Vivier <address@hidden> wrote:
>>>> This series is the result of coccinelle patch
>>>> scripts/coccinelle/exit.cocci
>>>> provided by the first patch of the series.
>>>>
>>>> It replaces exit(0) by exit(EXIT_SUCCESS)
>>>> and exit(1) by exit(EXIT_FAILURE).
>>>>
>>>> All other exit() are not modified as we don't want
>>>> to change the behavior.
>>>>
>>>> In some cases, I've added manually a line break to comply
>>>> with the maximum line length.
>>>
>>>> 182 files changed, 734 insertions(+), 715 deletions(-)
>>>
>>> You don't say why this is a useful change to make, and it's an
>>> awful lot of churn for a stylistic issue...
>>
>> Currently QEMU uses a mix of at least
>>
>> exit(EXIT_SUCCESS)
>> exit(EXIT_FAILURE)
>> exit(1)
>> exit(-1)
>> _exit(1)
>> _exit(0);
>>
>> so this series has the potential giving us more consistency style
>> and behaviour, across our code. By not fixing the up the usage of -1,
>> or fixing the _exit() usage, the series feels incomplete to me though.
>
> -1 is just a bug which we should fix (as Eric says). I don't
> see the point in converting all our 0s and 1s to EXIT_SUCCESS
> and EXIT_FAILURE though. (It would be less churn to convert the
> uses of EXIT_* to 0 and 1...)
Portability?
https://www.gnu.org/software/libc/manual/html_node/Exit-Status.html
-----------------------------------------------------------------------
Portability note: Some non-POSIX systems use different conventions for
exit status values. For greater portability, you can use the macros
EXIT_SUCCESS and EXIT_FAILURE for the conventional status value for
success and failure, respectively. They are declared in the file stdlib.h.
Macro: int EXIT_SUCCESS
This macro can be used with the exit function to indicate successful
program completion.
On POSIX systems, the value of this macro is 0. On other systems, the
value might be some other (possibly non-constant) integer expression.
Macro: int EXIT_FAILURE
This macro can be used with the exit function to indicate unsuccessful
program completion in a general sense.
On POSIX systems, the value of this macro is 1. On other systems, the
value might be some other (possibly non-constant) integer expression.
Other nonzero status values also indicate failures. Certain programs use
different nonzero status values to indicate particular kinds of
"non-success". For example, diff uses status value 1 to mean that the
files are different, and 2 or more to mean that there was difficulty in
opening the files.
-----------------------------------------------------------------------
What bothers me is some exit() use 0s and 1s, and some others EXIT_
macros. If you want to use 0s and 1s I have no problem with that, I have
just to update the coccinelle script.
Laurent
- [Qemu-devel] [PATCH 20/26] common: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE), (continued)
- [Qemu-devel] [PATCH 20/26] common: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE), Laurent Vivier, 2016/09/16
- [Qemu-devel] [PATCH 22/26] blockdev: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE), Laurent Vivier, 2016/09/16
- [Qemu-devel] [PATCH 16/26] s390: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE), Laurent Vivier, 2016/09/16
- [Qemu-devel] [PATCH 23/26] core: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE), Laurent Vivier, 2016/09/16
- Re: [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE), no-reply, 2016/09/16
- Re: [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE), Peter Maydell, 2016/09/16
Re: [Qemu-devel] [PATCH 00/26] trivial: use exit(EXIT_SUCCESS) and exit(EXIT_FAILURE), Daniel P. Berrange, 2016/09/16