hstore compiler warnings

Started by Kevin Grittneralmost 13 years ago4 messages
#1Kevin Grittner
kgrittn@ymail.com

Is anyone looking at these?:

hstore_io.c: In function ‘hstore_to_json_loose’:
hstore_io.c:1312:5: warning: ignoring return value of ‘strtol’, declared with attribute warn_unused_result [-Wunused-result]
hstore_io.c:1324:6: warning: ignoring return value of ‘strtod’, declared with attribute warn_unused_result [-Wunused-result]

gcc (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2

These warnings seem to have started with:

http://git.postgresql.org/gitweb/?p=postgresql.git;h=38fb4d978c5bfc377ef979e2595e3472744a3b05

--
Kevin Grittner
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#2Andrew Dunstan
andrew@dunslane.net
In reply to: Kevin Grittner (#1)
Re: hstore compiler warnings

On 03/21/2013 10:46 AM, Kevin Grittner wrote:

Is anyone looking at these?:

hstore_io.c: In function ‘hstore_to_json_loose’:
hstore_io.c:1312:5: warning: ignoring return value of ‘strtol’, declared with attribute warn_unused_result [-Wunused-result]
hstore_io.c:1324:6: warning: ignoring return value of ‘strtod’, declared with attribute warn_unused_result [-Wunused-result]

gcc (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2

These warnings seem to have started with:

http://git.postgresql.org/gitweb/?p=postgresql.git;h=38fb4d978c5bfc377ef979e2595e3472744a3b05

I thought we'd got rid of those. And they don't pop up on my F16 dev box
(gcc 4.6.2)

I'll check it out.

cheers

andrew

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Andrew Dunstan
andrew@dunslane.net
In reply to: Andrew Dunstan (#2)
1 attachment(s)
Re: hstore compiler warnings

On 03/21/2013 11:18 AM, Andrew Dunstan wrote:

On 03/21/2013 10:46 AM, Kevin Grittner wrote:

Is anyone looking at these?:

hstore_io.c: In function ‘hstore_to_json_loose’:
hstore_io.c:1312:5: warning: ignoring return value of ‘strtol’,
declared with attribute warn_unused_result [-Wunused-result]
hstore_io.c:1324:6: warning: ignoring return value of ‘strtod’,
declared with attribute warn_unused_result [-Wunused-result]

gcc (Ubuntu/Linaro 4.7.2-2ubuntu1) 4.7.2

These warnings seem to have started with:

http://git.postgresql.org/gitweb/?p=postgresql.git;h=38fb4d978c5bfc377ef979e2595e3472744a3b05

I thought we'd got rid of those. And they don't pop up on my F16 dev
box (gcc 4.6.2)

I'll check it out.

This is the only thing that I have found to work with very recent gcc.
Seems ugly. Anyone got a better idea?

cheers

andrew

Attachments:

unused-fix.patchtext/x-patch; name=unused-fix.patchDownload
diff --git a/contrib/hstore/hstore_io.c b/contrib/hstore/hstore_io.c
index a9a55d8..db63ae9 100644
--- a/contrib/hstore/hstore_io.c
+++ b/contrib/hstore/hstore_io.c
@@ -1308,8 +1308,9 @@ hstore_to_json_loose(PG_FUNCTION_ARGS)
                                 * value
                                 */
                                char       *endptr = "junk";
+                               long ljunk = strtol(src->data, &endptr, 10);
 
-                               (void) strtol(src->data, &endptr, 10);
+                               (void) ljunk;
                                if (*endptr == '\0')
                                {
                                        /*
@@ -1321,7 +1322,9 @@ hstore_to_json_loose(PG_FUNCTION_ARGS)
                                else
                                {
                                        /* not an int - try a double */
-                                       (void) strtod(src->data, &endptr);
+                                       double djunk = strtod(src->data, &endptr);
+
+                                       (void) djunk;
                                        if (*endptr == '\0')
                                                is_number = true;
#4Kevin Grittner
kgrittn@ymail.com
In reply to: Andrew Dunstan (#3)
Re: hstore compiler warnings

Andrew Dunstan <andrew@dunslane.net> wrote:

[assign to local variable and then `(void) varname;` to avoid "unused" warning]

This is the only thing that I have found to work with very recent gcc. Seems

ugly. Anyone got a better idea?

That seems to be what we've used elsewhere.

/messages/by-id/24446.1318973105@sss.pgh.pa.us

--
Kevin Grittner
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers