diff mbox

helper: linux: catch possible undefined

Message ID 1437745773-19713-1-git-send-email-mike.holmes@linaro.org
State Accepted
Commit cd582949369ac9a659b133f1a3259717e4a9fa44
Headers show

Commit Message

Mike Holmes July 24, 2015, 1:49 p.m. UTC
It is possible that wait will return a valid pid but have failed to have
set a status. Set a default status so that if this occurs the value will
be known and not garbage.

Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
---
 helper/linux.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Bill Fischofer July 24, 2015, 2:49 p.m. UTC | #1
Not sure why this is needed.  Per man:

 If *status* is not NULL, *wait*() and *waitpid*() store status information
       in the *int* to which it points.




On Fri, Jul 24, 2015 at 8:49 AM, Mike Holmes <mike.holmes@linaro.org> wrote:

> It is possible that wait will return a valid pid but have failed to have
> set a status. Set a default status so that if this occurs the value will
> be known and not garbage.
>
> Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
> ---
>  helper/linux.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/helper/linux.c b/helper/linux.c
> index 4256f43..3d3b6b8 100644
> --- a/helper/linux.c
> +++ b/helper/linux.c
> @@ -198,7 +198,7 @@ int odph_linux_process_wait_n(odph_linux_process_t
> *proc_tbl, int num)
>  {
>         pid_t pid;
>         int i, j;
> -       int status;
> +       int status = 0;
>
>         for (i = 0; i < num; i++) {
>                 pid = wait(&status);
> --
> 2.1.4
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
>
Mike Holmes July 24, 2015, 2:53 p.m. UTC | #2
On 24 July 2015 at 10:49, Bill Fischofer <bill.fischofer@linaro.org> wrote:

> Not sure why this is needed.  Per man:
>
>  If *status* is not NULL, *wait*() and *waitpid*() store status information
>        in the *int* to which it points.
>
> Indeed, I poked through those docs too but clang takes the view that it
cant see the code for wait and so it is possible that an implementation of
it that is linked to is suspect.
Unless the setting of the default is a problem for us in our unit test I'd
like to just kill the noise in the logs.


>
>
>
> On Fri, Jul 24, 2015 at 8:49 AM, Mike Holmes <mike.holmes@linaro.org>
> wrote:
>
>> It is possible that wait will return a valid pid but have failed to have
>> set a status. Set a default status so that if this occurs the value will
>> be known and not garbage.
>>
>> Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
>> ---
>>  helper/linux.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/helper/linux.c b/helper/linux.c
>> index 4256f43..3d3b6b8 100644
>> --- a/helper/linux.c
>> +++ b/helper/linux.c
>> @@ -198,7 +198,7 @@ int odph_linux_process_wait_n(odph_linux_process_t
>> *proc_tbl, int num)
>>  {
>>         pid_t pid;
>>         int i, j;
>> -       int status;
>> +       int status = 0;
>>
>>         for (i = 0; i < num; i++) {
>>                 pid = wait(&status);
>> --
>> 2.1.4
>>
>> _______________________________________________
>> lng-odp mailing list
>> lng-odp@lists.linaro.org
>> https://lists.linaro.org/mailman/listinfo/lng-odp
>>
>
>
Bill Fischofer July 24, 2015, 2:59 p.m. UTC | #3
No biggie.  Must keep those compilers happy :)

Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org>

On Fri, Jul 24, 2015 at 9:53 AM, Mike Holmes <mike.holmes@linaro.org> wrote:

>
>
> On 24 July 2015 at 10:49, Bill Fischofer <bill.fischofer@linaro.org>
> wrote:
>
>> Not sure why this is needed.  Per man:
>>
>>  If *status* is not NULL, *wait*() and *waitpid*() store status information
>>        in the *int* to which it points.
>>
>> Indeed, I poked through those docs too but clang takes the view that it
> cant see the code for wait and so it is possible that an implementation of
> it that is linked to is suspect.
> Unless the setting of the default is a problem for us in our unit test I'd
> like to just kill the noise in the logs.
>
>
>>
>>
>>
>> On Fri, Jul 24, 2015 at 8:49 AM, Mike Holmes <mike.holmes@linaro.org>
>> wrote:
>>
>>> It is possible that wait will return a valid pid but have failed to have
>>> set a status. Set a default status so that if this occurs the value will
>>> be known and not garbage.
>>>
>>> Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
>>> ---
>>>  helper/linux.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/helper/linux.c b/helper/linux.c
>>> index 4256f43..3d3b6b8 100644
>>> --- a/helper/linux.c
>>> +++ b/helper/linux.c
>>> @@ -198,7 +198,7 @@ int odph_linux_process_wait_n(odph_linux_process_t
>>> *proc_tbl, int num)
>>>  {
>>>         pid_t pid;
>>>         int i, j;
>>> -       int status;
>>> +       int status = 0;
>>>
>>>         for (i = 0; i < num; i++) {
>>>                 pid = wait(&status);
>>> --
>>> 2.1.4
>>>
>>> _______________________________________________
>>> lng-odp mailing list
>>> lng-odp@lists.linaro.org
>>> https://lists.linaro.org/mailman/listinfo/lng-odp
>>>
>>
>>
>
>
> --
> Mike Holmes
> Technical Manager - Linaro Networking Group
> Linaro.org <http://www.linaro.org/> *│ *Open source software for ARM SoCs
>
>
>
Maxim Uvarov July 27, 2015, 8:56 a.m. UTC | #4
Merged,
Maxim.

On 07/24/15 17:59, Bill Fischofer wrote:
> No biggie.  Must keep those compilers happy :)
>
> Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org 
> <mailto:bill.fischofer@linaro.org>>
>
> On Fri, Jul 24, 2015 at 9:53 AM, Mike Holmes <mike.holmes@linaro.org 
> <mailto:mike.holmes@linaro.org>> wrote:
>
>
>
>     On 24 July 2015 at 10:49, Bill Fischofer
>     <bill.fischofer@linaro.org <mailto:bill.fischofer@linaro.org>> wrote:
>
>         Not sure why this is needed.  Per man:
>
>           If/status/  is not NULL,*wait*() and*waitpid*() store status information
>                 in the/int/  to which it points.
>
>     Indeed, I poked through those docs too but clang takes the view
>     that it cant see the code for wait and so it is possible that an
>     implementation of it that is linked to is suspect.
>     Unless the setting of the default is a problem for us in our unit
>     test I'd like to just kill the noise in the logs.
>
>
>         On Fri, Jul 24, 2015 at 8:49 AM, Mike Holmes
>         <mike.holmes@linaro.org <mailto:mike.holmes@linaro.org>> wrote:
>
>             It is possible that wait will return a valid pid but have
>             failed to have
>             set a status. Set a default status so that if this occurs
>             the value will
>             be known and not garbage.
>
>             Signed-off-by: Mike Holmes <mike.holmes@linaro.org
>             <mailto:mike.holmes@linaro.org>>
>             ---
>              helper/linux.c | 2 +-
>              1 file changed, 1 insertion(+), 1 deletion(-)
>
>             diff --git a/helper/linux.c b/helper/linux.c
>             index 4256f43..3d3b6b8 100644
>             --- a/helper/linux.c
>             +++ b/helper/linux.c
>             @@ -198,7 +198,7 @@ int
>             odph_linux_process_wait_n(odph_linux_process_t *proc_tbl,
>             int num)
>              {
>                     pid_t pid;
>                     int i, j;
>             -       int status;
>             +       int status = 0;
>
>                     for (i = 0; i < num; i++) {
>                             pid = wait(&status);
>             --
>             2.1.4
>
>             _______________________________________________
>             lng-odp mailing list
>             lng-odp@lists.linaro.org <mailto:lng-odp@lists.linaro.org>
>             https://lists.linaro.org/mailman/listinfo/lng-odp
>
>
>
>
>
>     -- 
>     Mike Holmes
>     Technical Manager - Linaro Networking Group
>     Linaro.org <http://www.linaro.org/>***│ *Open source software for
>     ARM SoCs
>
>
>
>
> _______________________________________________
> lng-odp mailing list
> lng-odp@lists.linaro.org
> https://lists.linaro.org/mailman/listinfo/lng-odp
diff mbox

Patch

diff --git a/helper/linux.c b/helper/linux.c
index 4256f43..3d3b6b8 100644
--- a/helper/linux.c
+++ b/helper/linux.c
@@ -198,7 +198,7 @@  int odph_linux_process_wait_n(odph_linux_process_t *proc_tbl, int num)
 {
 	pid_t pid;
 	int i, j;
-	int status;
+	int status = 0;
 
 	for (i = 0; i < num; i++) {
 		pid = wait(&status);