Re: ecpg compiler warning about char* comparison

Lists: pgsql-hackers
From: Takahiro Itagaki <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org
Subject: ecpg compiler warning about char* comparison
Date: 2010-03-08 01:46:03
Message-ID: 20100308104602.9C53.52131E4D@oss.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

There is a complier warning in ecpg/ecpglib/error.c on HEAD:

error.c: In function 'eecpg_raise_backend':
error.c:309: warning: comparison with string literal results in unspecified behavior

It comes from the following coparison:
---
#define ECPG_SQLSTATE_ECPG_INTERNAL_ERROR "YE000"
char *sqlstate;
if (sqlstate == ECPG_SQLSTATE_ECPG_INTERNAL_ERROR)
---

Instead, should we use "if (strcmp(...) == 0)" here?

Regards,
---
Takahiro Itagaki
NTT Open Source Software Center


From: Michael Meskes <meskes(at)postgresql(dot)org>
To: Takahiro Itagaki <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: ecpg compiler warning about char* comparison
Date: 2010-03-08 12:15:10
Message-ID: 20100308121510.GA12566@feivel.credativ.lan
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, Mar 08, 2010 at 10:46:03AM +0900, Takahiro Itagaki wrote:
> There is a complier warning in ecpg/ecpglib/error.c on HEAD:
> ...
> Instead, should we use "if (strcmp(...) == 0)" here?

Exactly. Thanks for spotting this, fixed in HEAD.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ 179140304, AIM/Yahoo/Skype michaelmeskes, Jabber meskes(at)jabber(dot)org
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL