Small code clean-up

From: ITAGAKI Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: pgsql-patches(at)postgresql(dot)org
Subject: Small code clean-up
Date: 2007-03-28 01:23:09
Message-ID: 20070328100409.63CD.ITAGAKI.TAKAHIRO@oss.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Here are two small code clean-up in initdb and win32_shmem.

pg_char_to_encoding() was redundant in initdb because
pg_valid_server_encoding() returns the same result if the encoding is valid,

Changes in win32_shmem suppress the following warnings.
| pg_shmem.c: In function `PGSharedMemoryCreate':
| pg_shmem.c:137: warning: long unsigned int format, Size arg (arg 2)
| pg_shmem.c:159: warning: long unsigned int format, Size arg (arg 2)

*** initdb.c.orig Mon Mar 19 01:50:43 2007
--- initdb.c Wed Mar 28 10:02:42 2007
*************** get_encoding_id(char *encoding_name)
*** 709,716 ****

if (encoding_name && *encoding_name)
{
! if ((enc = pg_char_to_encoding(encoding_name)) >= 0 &&
! pg_valid_server_encoding(encoding_name) >= 0)
return encodingid_to_string(enc);
}
fprintf(stderr, _("%s: \"%s\" is not a valid server encoding name\n"),
--- 709,715 ----

if (encoding_name && *encoding_name)
{
! if ((enc = pg_valid_server_encoding(encoding_name)) >= 0)
return encodingid_to_string(enc);
}
fprintf(stderr, _("%s: \"%s\" is not a valid server encoding name\n"),

*** win32_shmem.c.orig Wed Mar 28 10:17:14 2007
--- win32_shmem.c Wed Mar 28 10:16:36 2007
*************** PGSharedMemoryCreate(Size size, bool mak
*** 136,142 ****
if (!hmap)
ereport(FATAL,
(errmsg("could not create shared memory segment: %lu", GetLastError()),
! errdetail("Failed system call was CreateFileMapping(size=%lu, name=%s)", size, szShareMem)));

/*
* If the segment already existed, CreateFileMapping() will return a
--- 136,142 ----
if (!hmap)
ereport(FATAL,
(errmsg("could not create shared memory segment: %lu", GetLastError()),
! errdetail("Failed system call was CreateFileMapping(size=%lu, name=%s)", (unsigned long) size, szShareMem)));

/*
* If the segment already existed, CreateFileMapping() will return a
*************** PGSharedMemoryCreate(Size size, bool mak
*** 158,164 ****
if (!hmap)
ereport(FATAL,
(errmsg("could not create shared memory segment: %lu", GetLastError()),
! errdetail("Failed system call was CreateFileMapping(size=%lu, name=%s)", size, szShareMem)));

if (GetLastError() == ERROR_ALREADY_EXISTS)
ereport(FATAL,
--- 158,164 ----
if (!hmap)
ereport(FATAL,
(errmsg("could not create shared memory segment: %lu", GetLastError()),
! errdetail("Failed system call was CreateFileMapping(size=%lu, name=%s)", (unsigned long) size, szShareMem)));

if (GetLastError() == ERROR_ALREADY_EXISTS)
ereport(FATAL,

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

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Koichi Suzuki 2007-03-28 01:54:11 Re: [PATCHES] Full page writes improvement, code update
Previous Message Tom Lane 2007-03-28 01:01:30 Re: [PATCH] add CLUSTER table ORDER BY index