pg.ddx.io  pgsql-odbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Code inconsistency in convert.c for guid -> string conversion
5+ messages / 2 participants
[nested] [flat]

* Code inconsistency in convert.c for guid -> string conversion
@ 2014-03-03 02:38 Michael Paquier <michael.paquier@gmail.com>
  2014-03-03 02:41 ` Re: Code inconsistency in convert.c for guid -> string conversion Michael Paquier <michael.paquier@gmail.com>
  2014-03-03 19:44 ` Re: Code inconsistency in convert.c for guid -> string conversion Heikki Linnakangas <hlinnakangas@vmware.com>
  0 siblings, 2 replies; 5+ messages in thread

From: Michael Paquier @ 2014-03-03 02:38 UTC (permalink / raw)
  To: pgsql-odbc

Hi all,

While working on the code of odbc, I noticed an inconsistency in
convert.c, found by compiling the code with -Werror.

convert.c:4466: error: format '%08lX' expects type 'long unsigned
int', but argument 4 has type 'DWORD'

By looking closer at the code, the behavior in the code for guid ->
string conversion is inconsistent with char2guid using an sscan for
the similar reverse operation. I am attaching a patch fixing that.

On another note, I found as well the following warning:
dlg_specific.c:1491: error: the address of 'conn_settings' will always
evaluate as 'true'
All of this was reproduced using 09.03.0200.

Regards,
-- 
Michael

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

Attachments:

20140303_convert_warning.patch (text/plain, 713B) download diff --git a/convert.c b/convert.c index 69c1e26..d8b0304 100644 --- a/convert.c +++ b/convert.c @@ -4456,10 +4456,14 @@ mylog("C_WCHAR=%s(%d)\n", buffer, used); #if (ODBCVER >= 0x0350) case SQL_C_GUID: { + /* + * SQLGUID.Data1 is an "unsigned long" on some platforms, and + * "unsigned int" on others. + */ SQLGUID *g = (SQLGUID *) buffer; snprintf (param_string, sizeof(param_string), - "%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", - g->Data1, + "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X", + (unsigned int) g->Data1, g->Data2, g->Data3, g->Data4[0], g->Data4[1], g->Data4[2], g->Data4[3], g->Data4[4], g->Data4[5], g->Data4[6], g->Data4[7]);
^ permalink raw reply [nested|flat] 5+ messages in thread

* Re: Code inconsistency in convert.c for guid -> string conversion
  2014-03-03 02:38 Code inconsistency in convert.c for guid -> string conversion Michael Paquier <michael.paquier@gmail.com>
@ 2014-03-03 02:41 ` Michael Paquier <michael.paquier@gmail.com>
  2014-03-03 19:26   ` Re: Code inconsistency in convert.c for guid -> string conversion Heikki Linnakangas <hlinnakangas@vmware.com>
  1 sibling, 1 reply; 5+ messages in thread

From: Michael Paquier @ 2014-03-03 02:41 UTC (permalink / raw)
  To: pgsql-odbc

On Mon, Mar 3, 2014 at 11:38 AM, Michael Paquier
<michael.paquier@gmail.com> wrote:
> On another note, I found as well the following warning:
> dlg_specific.c:1491: error: the address of 'conn_settings' will always
> evaluate as 'true'
Sorry for the imprecision, this warning is caused by this code:
        if ('\0' != conn_settings[0])
            STR_TO_NAME(comval->conn_settings, conn_settings);
-- 
Michael


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



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Code inconsistency in convert.c for guid -> string conversion
  2014-03-03 02:38 Code inconsistency in convert.c for guid -> string conversion Michael Paquier <michael.paquier@gmail.com>
  2014-03-03 02:41 ` Re: Code inconsistency in convert.c for guid -> string conversion Michael Paquier <michael.paquier@gmail.com>
@ 2014-03-03 19:26   ` Heikki Linnakangas <hlinnakangas@vmware.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Heikki Linnakangas @ 2014-03-03 19:26 UTC (permalink / raw)
  To: Michael Paquier <michael.paquier@gmail.com>; +Cc: pgsql-odbc

On 03/03/2014 04:41 AM, Michael Paquier wrote:
> On Mon, Mar 3, 2014 at 11:38 AM, Michael Paquier
> <michael.paquier@gmail.com> wrote:
>> On another note, I found as well the following warning:
>> dlg_specific.c:1491: error: the address of 'conn_settings' will always
>> evaluate as 'true'
> Sorry for the imprecision, this warning is caused by this code:
>          if ('\0' != conn_settings[0])
>              STR_TO_NAME(comval->conn_settings, conn_settings);

Thanks, committed.

- Heikki


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



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Code inconsistency in convert.c for guid -> string conversion
  2014-03-03 02:38 Code inconsistency in convert.c for guid -> string conversion Michael Paquier <michael.paquier@gmail.com>
@ 2014-03-03 19:44 ` Heikki Linnakangas <hlinnakangas@vmware.com>
  2014-03-04 00:19   ` Re: Code inconsistency in convert.c for guid -> string conversion Michael Paquier <michael.paquier@gmail.com>
  1 sibling, 1 reply; 5+ messages in thread

From: Heikki Linnakangas @ 2014-03-03 19:44 UTC (permalink / raw)
  To: Michael Paquier <michael.paquier@gmail.com>; +Cc: pgsql-odbc

On 03/03/2014 04:38 AM, Michael Paquier wrote:
> On another note, I found as well the following warning:
> dlg_specific.c:1491: error: the address of 'conn_settings' will always
> evaluate as 'true'

Yeah, that has bothered me for a long time, but at a quick glance I 
haven't seen a very good way to fix it. Clearly the "conn_settings == 
NULL" test is unnecessary here, but the free() call that STR_TO_NAME 
also does is not, so we can't just replace the macro with an strcpy.

Hmm, now that I look at it, we have a macro STRX_TO_NAME which is the 
same but without the NULL check. So we can just use that; that appears 
to be how it's used elsewhere too.

So, fixed.

- Heikki


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



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Code inconsistency in convert.c for guid -> string conversion
  2014-03-03 02:38 Code inconsistency in convert.c for guid -> string conversion Michael Paquier <michael.paquier@gmail.com>
  2014-03-03 19:44 ` Re: Code inconsistency in convert.c for guid -> string conversion Heikki Linnakangas <hlinnakangas@vmware.com>
@ 2014-03-04 00:19   ` Michael Paquier <michael.paquier@gmail.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Michael Paquier @ 2014-03-04 00:19 UTC (permalink / raw)
  To: Heikki Linnakangas <hlinnakangas@vmware.com>; +Cc: pgsql-odbc

On Tue, Mar 4, 2014 at 4:44 AM, Heikki Linnakangas
<hlinnakangas@vmware.com> wrote:
> On 03/03/2014 04:38 AM, Michael Paquier wrote:
>>
>> On another note, I found as well the following warning:
>> dlg_specific.c:1491: error: the address of 'conn_settings' will always
>> evaluate as 'true'
>
>
> Yeah, that has bothered me for a long time, but at a quick glance I haven't
> seen a very good way to fix it. Clearly the "conn_settings == NULL" test is
> unnecessary here, but the free() call that STR_TO_NAME also does is not, so
> we can't just replace the macro with an strcpy.
>
> Hmm, now that I look at it, we have a macro STRX_TO_NAME which is the same
> but without the NULL check. So we can just use that; that appears to be how
> it's used elsewhere too.
Thanks, I was not sure how to fix this one as well.
-- 
Michael


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



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2014-03-04 00:19 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-03-03 02:38 Code inconsistency in convert.c for guid -> string conversion Michael Paquier <michael.paquier@gmail.com>
2014-03-03 02:41 ` Michael Paquier <michael.paquier@gmail.com>
2014-03-03 19:26   ` Heikki Linnakangas <hlinnakangas@vmware.com>
2014-03-03 19:44 ` Heikki Linnakangas <hlinnakangas@vmware.com>
2014-03-04 00:19   ` Michael Paquier <michael.paquier@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox