Patchwork [01/26] lib: fwts_acpid: fix checking of return from read()

login
register
mail settings
Submitter Colin King
Date Oct. 14, 2012, 8:31 p.m.
Message ID <1350246738-31699-2-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/191392/
State Accepted
Headers show

Comments

Colin King - Oct. 14, 2012, 8:31 p.m.
From: Colin Ian King <colin.king@canonical.com>

The return from a read() is of type ssize_t and not size_t and
were are currently checking for n < 0 which will never happen if
n is a size_t type.  So make it ssize_t.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/src/fwts_acpid.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Alex Hung - Oct. 15, 2012, 2:17 a.m.
On 10/15/2012 04:31 AM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The return from a read() is of type ssize_t and not size_t and
> were are currently checking for n < 0 which will never happen if
> n is a size_t type.  So make it ssize_t.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/src/fwts_acpid.c |    2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/lib/src/fwts_acpid.c b/src/lib/src/fwts_acpid.c
> index 3107052..c7e5c43 100644
> --- a/src/lib/src/fwts_acpid.c
> +++ b/src/lib/src/fwts_acpid.c
> @@ -77,7 +77,7 @@ char *fwts_acpi_event_read(const int fd, size_t *length, const int timeout)
>   	fd_set rfds;
>
>   	int ret;
> -	size_t n;
> +	ssize_t n;
>   	size_t size = 0;
>   	*length = 0;
>
>

Acked-by: Alex Hung <alex.hung@canonical.com>
Keng-Yu Lin - Oct. 17, 2012, 7:37 a.m.
On Mon, Oct 15, 2012 at 4:31 AM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> The return from a read() is of type ssize_t and not size_t and
> were are currently checking for n < 0 which will never happen if
> n is a size_t type.  So make it ssize_t.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_acpid.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/src/lib/src/fwts_acpid.c b/src/lib/src/fwts_acpid.c
> index 3107052..c7e5c43 100644
> --- a/src/lib/src/fwts_acpid.c
> +++ b/src/lib/src/fwts_acpid.c
> @@ -77,7 +77,7 @@ char *fwts_acpi_event_read(const int fd, size_t *length, const int timeout)
>         fd_set rfds;
>
>         int ret;
> -       size_t n;
> +       ssize_t n;
>         size_t size = 0;
>         *length = 0;
>
> --
> 1.7.10.4
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>

Patch

diff --git a/src/lib/src/fwts_acpid.c b/src/lib/src/fwts_acpid.c
index 3107052..c7e5c43 100644
--- a/src/lib/src/fwts_acpid.c
+++ b/src/lib/src/fwts_acpid.c
@@ -77,7 +77,7 @@  char *fwts_acpi_event_read(const int fd, size_t *length, const int timeout)
 	fd_set rfds;
 
 	int ret;
-	size_t n;
+	ssize_t n;
 	size_t size = 0;
 	*length = 0;