2013-12-03 16:04:54

by Andrei Emeltchenko

[permalink] [raw]
Subject: [PATCH] obex: Fix checking incorrect error code

From: Andrei Emeltchenko <[email protected]>

chdir return -1 if error and 0 in success. Checking for > 0 is pointless.
---
tools/obex-server-tool.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/obex-server-tool.c b/tools/obex-server-tool.c
index e37c56f..86c2271 100644
--- a/tools/obex-server-tool.c
+++ b/tools/obex-server-tool.c
@@ -427,7 +427,7 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}

- if (option_root && chdir(option_root) > 0) {
+ if (option_root && chdir(option_root) < 0) {
perror("chdir:");
exit(EXIT_FAILURE);
}
--
1.8.3.2



2013-12-09 09:56:30

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH] obex: Fix checking incorrect error code

Hi Andrei,

On Mon, Dec 9, 2013 at 10:03 AM, Andrei Emeltchenko
<[email protected]> wrote:
> ping
>
> On Tue, Dec 03, 2013 at 06:04:54PM +0200, Andrei Emeltchenko wrote:
>> From: Andrei Emeltchenko <[email protected]>
>>
>> chdir return -1 if error and 0 in success. Checking for > 0 is pointless.
>> ---
>> tools/obex-server-tool.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tools/obex-server-tool.c b/tools/obex-server-tool.c
>> index e37c56f..86c2271 100644
>> --- a/tools/obex-server-tool.c
>> +++ b/tools/obex-server-tool.c
>> @@ -427,7 +427,7 @@ int main(int argc, char *argv[])
>> exit(EXIT_FAILURE);
>> }
>>
>> - if (option_root && chdir(option_root) > 0) {
>> + if (option_root && chdir(option_root) < 0) {
>> perror("chdir:");
>> exit(EXIT_FAILURE);
>> }
>> --
>> 1.8.3.2

Pushed, thanks.


--
Luiz Augusto von Dentz

2013-12-09 08:03:11

by Andrei Emeltchenko

[permalink] [raw]
Subject: Re: [PATCH] obex: Fix checking incorrect error code

ping

On Tue, Dec 03, 2013 at 06:04:54PM +0200, Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <[email protected]>
>
> chdir return -1 if error and 0 in success. Checking for > 0 is pointless.
> ---
> tools/obex-server-tool.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/obex-server-tool.c b/tools/obex-server-tool.c
> index e37c56f..86c2271 100644
> --- a/tools/obex-server-tool.c
> +++ b/tools/obex-server-tool.c
> @@ -427,7 +427,7 @@ int main(int argc, char *argv[])
> exit(EXIT_FAILURE);
> }
>
> - if (option_root && chdir(option_root) > 0) {
> + if (option_root && chdir(option_root) < 0) {
> perror("chdir:");
> exit(EXIT_FAILURE);
> }
> --
> 1.8.3.2
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html