patch to fix unused variable warning on windows build

Lists: pgsql-hackers
From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: patch to fix unused variable warning on windows build
Date: 2013-11-07 06:13:59
Message-ID: CAApHDvp_sZ=zWMV4fFOy82ft24wSPnVMNfv0SUUA8Jud5vQBPA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Attached is a small patch which fixes the unused variable warning in the
visual studios build. Seems like VS does not
support __attribute__((unused)) but looks like all other places we must
assign to the variable.

Regards

David Rowley

Attachment Content-Type Size
unused_variable.patch application/octet-stream 758 bytes

From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch to fix unused variable warning on windows build
Date: 2013-11-09 06:29:38
Message-ID: CAA4eK1+F+kNi+DqeGqJ_2y1FpTi-CVH4QyMC4ODDXWhOZ54nkw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, Nov 7, 2013 at 11:43 AM, David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
> Attached is a small patch which fixes the unused variable warning in the
> visual studios build. Seems like VS does not support
> __attribute__((unused)) but looks like all other places we must assign to
> the variable.

I have raised same issue some time back, see the below link where
there is some discussion about it.
http://www.postgresql.org/message-id/CAA4eK1JEOa1hJGAUwPcqhw8av7zAPkDxJdwUbwEtjomi2f8hFg@mail.gmail.com

I think it is good, if one of committer's who have windows env. can
look into it and commit or provide suggestions, else you can make a
combined patch of this and other warning you saw on windows and upload
to next CF so that it doesn't get lost.
I checked that you have already submitted a patch for this warning
alone in CF.

With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com


From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch to fix unused variable warning on windows build
Date: 2013-11-09 07:30:14
Message-ID: CAApHDvrAMLrFuFyw_gxeU9bRzjU_V9RfONgXozv_GRsojfmtFw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, Nov 9, 2013 at 7:29 PM, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:

> On Thu, Nov 7, 2013 at 11:43 AM, David Rowley <dgrowleyml(at)gmail(dot)com>
> wrote:
> > Attached is a small patch which fixes the unused variable warning in the
> > visual studios build. Seems like VS does not support
> > __attribute__((unused)) but looks like all other places we must assign to
> > the variable.
>
> I have raised same issue some time back, see the below link where
> there is some discussion about it.
>
> http://www.postgresql.org/message-id/CAA4eK1JEOa1hJGAUwPcqhw8av7zAPkDxJdwUbwEtjomi2f8hFg@mail.gmail.com
>
>
Thanks for the link.
The reason that we don't see more warnings for this is that it seems in all
other places where we have used PG_USED_FOR_ASSERTS_ONLY, the variable is
getting assigned to every time, though it will only be when compiled in
debug that the variable is checked. It seems microsoft decided to disable
warnings for assigned but not used for pretty much this reason.

http://stackoverflow.com/questions/10593547/why-is-no-warning-given-for-this-unused-variable

"Microsoft explain that it's because they had lots of complaints from
people who were assigning variables purely so they could see what a method
call returned during debugging, and found the warning irritating:"

So I guess fixing up PG_USED_FOR_ASSERTS_ONLY to work with visual studios
is not required and my patch seems like the fix for this unique case.

> I think it is good, if one of committer's who have windows env. can
> look into it and commit or provide suggestions, else you can make a
> combined patch of this and other warning you saw on windows and upload
> to next CF so that it doesn't get lost.
> I checked that you have already submitted a patch for this warning
> alone in CF.
>
>
I was not quite sure what I should do for these tiny patches. Quite often
if a committer happens to read the post and agrees with the patch then it
might get committed pretty quickly even outside a commitfest, but if not
then if I didn't add to the commitfest then it would likely get lost.

Regards

David Rowley

> With Regards,
> Amit Kapila.
> EnterpriseDB: http://www.enterprisedb.com
>


From: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch to fix unused variable warning on windows build
Date: 2013-11-10 03:59:24
Message-ID: CAA4eK1+dRKCeMMJnTH8aOkBU+Kk04sE_5vbJP2GE1ycgnmOmTg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, Nov 9, 2013 at 1:00 PM, David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
> On Sat, Nov 9, 2013 at 7:29 PM, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
>>
> Thanks for the link.
> The reason that we don't see more warnings for this is that it seems in all
> other places where we have used PG_USED_FOR_ASSERTS_ONLY, the variable is
> getting assigned to every time, though it will only be when compiled in
> debug that the variable is checked. It seems microsoft decided to disable
> warnings for assigned but not used for pretty much this reason.
>
> http://stackoverflow.com/questions/10593547/why-is-no-warning-given-for-this-unused-variable
>
> "Microsoft explain that it's because they had lots of complaints from people
> who were assigning variables purely so they could see what a method call
> returned during debugging, and found the warning irritating:"
>
> So I guess fixing up PG_USED_FOR_ASSERTS_ONLY to work with visual studios is
> not required and my patch seems like the fix for this unique case.

You are right that for this case it is sufficient to fix it the way
you have done in patch. However it
might be the case that here expectation is to provide a generic
solution for such kind of warnings
(as it doesn't occur on linux or other OS) so that in future such a
case should not arise.

>
>>
>> I think it is good, if one of committer's who have windows env. can
>> look into it and commit or provide suggestions, else you can make a
>> combined patch of this and other warning you saw on windows and upload
>> to next CF so that it doesn't get lost.
>> I checked that you have already submitted a patch for this warning
>> alone in CF.
>>
>
> I was not quite sure what I should do for these tiny patches. Quite often if
> a committer happens to read the post and agrees with the patch then it might
> get committed pretty quickly even outside a commitfest, but if not then if I
> didn't add to the commitfest then it would likely get lost.

You have done the right thing.

With Regards,
Amit Kapila.
EnterpriseDB: http://www.enterprisedb.com


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: patch to fix unused variable warning on windows build
Date: 2013-11-13 11:32:30
Message-ID: 1384342350.15453.0.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, 2013-11-07 at 19:13 +1300, David Rowley wrote:
> Attached is a small patch which fixes the unused variable warning in
> the visual studios build. Seems like VS does not
> support __attribute__((unused)) but looks like all other places we
> must assign to the variable.
>
committed