1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-18 02:02:55 +03:00

Add do { ... } while (0) to more bad macros.

This commit is contained in:
Bruce Momjian
2001-10-25 01:29:37 +00:00
parent b4a57b0648
commit fde8edaf53
13 changed files with 89 additions and 42 deletions

View File

@@ -27,7 +27,11 @@
#else /* not HAVE_DLOPEN */
#define pg_dlsym(handle, funcname) ((PGFunction) dld_get_func((funcname)))
#define pg_dlclose(handle) ({ dld_unlink_by_file(handle, 1); free(handle); })
#define pg_dlclose(handle) \
do { \
dld_unlink_by_file(handle, 1); \
free(handle); \
} while (0)
#endif /* not HAVE_DLOPEN */

View File

@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: linux.h,v 1.12 2001/05/14 21:45:53 petere Exp $
* $Id: linux.h,v 1.13 2001/10/25 01:29:37 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -23,10 +23,15 @@
#ifndef HAVE_DLD_H
#define pg_dlsym(handle, funcname) (NULL)
#define pg_dlclose(handle) ({})
#define pg_dlclose(handle) {}
#else
#define pg_dlsym(handle, funcname) ((PGFunction) dld_get_func((funcname)))
#define pg_dlclose(handle) ({ dld_unlink_by_file(handle, 1); free(handle); })
#define pg_dlclose(handle) \
do { \
dld_unlink_by_file(handle, 1); \
free(handle); \
} while (0)
#endif
#else /* HAVE_DLOPEN */

View File

@@ -129,7 +129,12 @@ static int pg_isprint(int c);
#ifdef REDEBUG
#define SP(t, s, c) print(m, t, s, c, stdout)
#define AT(t, p1, p2, s1, s2) at(m, t, p1, p2, s1, s2)
#define NOTE(str) { if (m->eflags&REG_TRACE) printf("=%s\n", (str)); }
#define NOTE(str) \
do { \
if (m->eflags&REG_TRACE) \
printf("=%s\n", (str)); \
} while (0)
#else
#define SP(t, s, c) /* nothing */
#define AT(t, p1, p2, s1, s2) /* nothing */

View File

@@ -114,10 +114,19 @@ static int nope = 0; /* for use in asserts; shuts lint up */
#define ASSIGN(d, s) memcpy(d, s, m->g->nstates)
#define EQ(a, b) (memcmp(a, b, m->g->nstates) == 0)
#define STATEVARS int vn; char *space
#define STATESETUP(m, nv) { (m)->space = malloc((nv)*(m)->g->nstates); \
if ((m)->space == NULL) return(REG_ESPACE); \
(m)->vn = 0; }
#define STATETEARDOWN(m) { free((m)->space); }
#define STATESETUP(m, nv) \
do { \
(m)->space = malloc((nv)*(m)->g->nstates); \
if ((m)->space == NULL) \
return(REG_ESPACE); \
(m)->vn = 0; \
} while (0)
#define STATETEARDOWN(m) \
do { \
free((m)->space); \
} while (0)
#define SETUP(v) ((v) = &m->space[m->vn++ * m->g->nstates])
#define onestate int
#define INIT(o, n) ((o) = (n))

View File

@@ -1,7 +1,7 @@
/* ----------
* pg_lzcompress.c -
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.11 2001/03/22 06:16:17 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.12 2001/10/25 01:29:37 momjian Exp $
*
* This is an implementation of LZ compression for PostgreSQL.
* It uses a simple history table and generates 2-3 byte tags
@@ -283,7 +283,8 @@ static PGLZ_HistEntry hist_entries[PGLZ_HISTORY_SIZE];
* Adds a new entry to the history table.
* ----------
*/
#define pglz_hist_add(_hs,_he,_hn,_s,_e) { \
#define pglz_hist_add(_hs,_he,_hn,_s,_e) \
do { \
int __hindex = pglz_hist_idx((_s),(_e)); \
if ((_he)[(_hn)].prev == NULL) { \
(_hs)[__hindex] = (_he)[(_hn)].next; \
@@ -303,7 +304,7 @@ static PGLZ_HistEntry hist_entries[PGLZ_HISTORY_SIZE];
if (++(_hn) >= PGLZ_HISTORY_SIZE) { \
(_hn) = 0; \
} \
}
} while (0)
/* ----------
@@ -312,7 +313,8 @@ static PGLZ_HistEntry hist_entries[PGLZ_HISTORY_SIZE];
* Outputs the last and allocates a new control byte if needed.
* ----------
*/
#define pglz_out_ctrl(__ctrlp,__ctrlb,__ctrl,__buf) { \
#define pglz_out_ctrl(__ctrlp,__ctrlb,__ctrl,__buf) \
do { \
if ((__ctrl & 0xff) == 0) \
{ \
*__ctrlp = __ctrlb; \
@@ -320,7 +322,7 @@ static PGLZ_HistEntry hist_entries[PGLZ_HISTORY_SIZE];
__ctrlb = 0; \
__ctrl = 1; \
} \
}
} while (0)
/* ----------
@@ -330,11 +332,12 @@ static PGLZ_HistEntry hist_entries[PGLZ_HISTORY_SIZE];
* appropriate control bit.
* ----------
*/
#define pglz_out_literal(_ctrlp,_ctrlb,_ctrl,_buf,_byte) { \
#define pglz_out_literal(_ctrlp,_ctrlb,_ctrl,_buf,_byte) \
do { \
pglz_out_ctrl(_ctrlp,_ctrlb,_ctrl,_buf); \
*_buf++ = (unsigned char)(_byte); \
_ctrl <<= 1; \
}
} while (0)
/* ----------
@@ -345,7 +348,8 @@ static PGLZ_HistEntry hist_entries[PGLZ_HISTORY_SIZE];
* appropriate control bit.
* ----------
*/
#define pglz_out_tag(_ctrlp,_ctrlb,_ctrl,_buf,_len,_off) { \
#define pglz_out_tag(_ctrlp,_ctrlb,_ctrl,_buf,_len,_off) \
do { \
pglz_out_ctrl(_ctrlp,_ctrlb,_ctrl,_buf); \
_ctrlb |= _ctrl; \
_ctrl <<= 1; \
@@ -360,7 +364,7 @@ static PGLZ_HistEntry hist_entries[PGLZ_HISTORY_SIZE];
_buf[1] = (unsigned char)((_off) & 0xff); \
_buf += 2; \
} \
}
} while (0)
/* ----------