[PATCH] uemis-downloader.c: fix some read() and write() warnings

Dirk Hohndel dirk at hohndel.org
Wed Oct 9 07:10:15 UTC 2013


Well, this patch is one of those examples where I think fixing the
warnings is just stupid. You are just moving the same issue (in this
code I really don't care about the result of read) to a different spot
where the compiler doesn't notice. You now have all these ret variables
that get set and then ignored. There is another warning that we could
turn on that will then complain about that :-)

NAK

/D

On Wed, 2013-10-09 at 14:15 +0300, Lubomir I. Ivanov wrote:
> From: "Lubomir I. Ivanov" <neolit123 at gmail.com>
> 
> Patch fixes warnings for read() and write() not returning
> to a variable:
> "ignoring return value of write, declared with attribute
> warn_unused_result [-Wunused-result]"
> 
> Signed-off-by: Lubomir I. Ivanov <neolit123 at gmail.com>
> ---
>  uemis-downloader.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/uemis-downloader.c b/uemis-downloader.c
> index eced216..a9996e2 100644
> --- a/uemis-downloader.c
> +++ b/uemis-downloader.c
> @@ -188,7 +188,7 @@ static bool uemis_init(const char *path)
>  	}
>  	if (bytes_available(reqtxt_file) > 5) {
>  		char tmp[6];
> -		read(reqtxt_file, tmp, 5);
> +		int ret = read(reqtxt_file, tmp, 5);
>  		tmp[5] = '\0';
>  #if UEMIS_DEBUG & 2
>  		fprintf(debugfile, "::r req.txt \"%s\"\n", tmp);
> @@ -235,9 +235,9 @@ static void trigger_response(int file, char *command, int nr, long tailpos)
>  	fprintf(debugfile,":tr %s (after seeks)\n", fl);
>  #endif
>  	lseek(file, 0, SEEK_SET);
> -	write(file, fl, strlen(fl));
> +	int ret = write(file, fl, strlen(fl));
>  	lseek(file, tailpos, SEEK_SET);
> -	write(file, fl + 1, strlen(fl + 1));
> +	ret = write(file, fl + 1, strlen(fl + 1));
>  #ifndef WIN32
>  	fsync(file);
>  #endif
> @@ -427,7 +427,7 @@ static bool uemis_get_answer(const char *path, char *request, int n_param_in,
>  		snprintf(fl, 13, "ANS%d.TXT", filenr - 1);
>  		ans_path = build_filename(build_filename(path, "ANS"), fl);
>  		ans_file = open(ans_path, O_RDONLY, 0666);
> -		read(ans_file, tmp, 100);
> +		int ret = read(ans_file, tmp, 100);
>  		close(ans_file);
>  #if UEMIS_DEBUG & 8
>  		tmp[100]='\0';
> @@ -478,7 +478,7 @@ static bool uemis_get_answer(const char *path, char *request, int n_param_in,
>  			if (size > 3) {
>  				char *buf = malloc(size - 2);
>  				lseek(ans_file, 3, SEEK_CUR);
> -				read(ans_file, buf, size - 3);
> +				int ret = read(ans_file, buf, size - 3);
>  				buf[size - 3] = '\0';
>  				buffer_add(&mbuf, &mbuf_size, buf);
>  				show_progress(buf, what);
> @@ -502,7 +502,7 @@ static bool uemis_get_answer(const char *path, char *request, int n_param_in,
>  			if (size > 3) {
>  				buf = malloc(size - 2);
>  				lseek(ans_file, 3, SEEK_CUR);
> -				read(ans_file, buf, size - 3);
> +				int ret = read(ans_file, buf, size - 3);
>  				buf[size - 3] = '\0';
>  				buffer_add(&mbuf, &mbuf_size, buf);
>  				show_progress(buf, what);
> _______________________________________________
> subsurface mailing list
> subsurface at hohndel.org
> http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface




More information about the subsurface mailing list