1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-22 12:22:45 +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

@@ -817,7 +817,10 @@ do { \
* Terminate the stmt_with_params string with NULL.
*----------
*/
#define CVT_TERMINATE { new_statement[npos] = '\0'; }
#define CVT_TERMINATE \
do { \
new_statement[npos] = '\0'; \
} while (0)
/*----------
* Append a data.
@@ -1434,7 +1437,7 @@ copy_statement_with_parameters(StatementClass *stmt)
/* error */
stmt->errormsg = "Unrecognized C_parameter type in copy_statement_with_parameters";
stmt->errornumber = STMT_NOT_IMPLEMENTED_ERROR;
CVT_TERMINATE /* just in case */
CVT_TERMINATE; /* just in case */
SC_log_error(func, "", stmt);
return SQL_ERROR;
}
@@ -1684,7 +1687,7 @@ copy_statement_with_parameters(StatementClass *stmt)
} /* end, for */
/* make sure new_statement is always null-terminated */
CVT_TERMINATE
CVT_TERMINATE;
if (conn->DriverToDataSource != NULL)
{

View File

@@ -8,7 +8,11 @@
#include <sys/types.h>
#define MEM_ALLOC(size) (malloc((size_t)(size)))
#define MEM_FREE(ptr) {if(ptr) free(ptr);}
#define MEM_FREE(ptr) \
do { \
if(ptr) \
free(ptr); \
} while (0)
#define STRCPY(t, s) (strcpy((char*)(t), (char*)(s)))
#define STRNCPY(t,s,n) (strncpy((char*)(t), (char*)(s), (size_t)(n)))