Re: pg_tablespace_databases

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Andreas Pflug <pgadmin(at)pse-consulting(dot)de>, Joe Conway <mail(at)joeconway(dot)com>, PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: pg_tablespace_databases
Date: 2004-07-06 15:00:27
Message-ID: 200407061500.i66F0Rs28680@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > Tom Lane wrote:
> >> [ shrug... ] The name is not going to change again. I have never cared
> >> for the practice of writing strlen("foo") as if it were a compile-time
> >> constant.
>
> > I think with gcc strlen("foo") is a compile-time constant.
>
> Portability is exactly the root of the problem. If you are in the habit
> of doing this then you get led into unportable behaviors like
> char localarray[strlen(foo) + 1];
> which no compiler except gcc will take. (We just had to fix exactly
> that mistake in someone's patch within the last week or two.)

One idea would be to create a CONST_STRLEN macro that uses sizeof()-1.

> > What do you prefer?
>
> I use "3" ;-). As long as the size calculation and the filling of the
> string are immediately adjacent, the purpose of the code is clear
> enough.

If it is on the same line, yea, it is clear, but often the size refers
to something declared several lines away.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-patches by date

  From Date Subject
Next Message Pavel Stehule 2004-07-06 15:43:53 actualized czech FAQ again
Previous Message Bruce Momjian 2004-07-06 14:20:28 Re: [PATCH] s_lock support for win32