Skip to content

Commit

Permalink
Surround multiline macros
Browse files Browse the repository at this point in the history
ma_helper.h:97:3: warning: macro expands to multiple statements [-Wmultistatement-macros]
   97 |   free((a));\
      |   ^~~~
ma_string.c:387:5: note: in expansion of macro 'MADB_FREE'
  387 |     MADB_FREE(StmtStr);
      |     ^~~~~~~~~
ma_string.c:386:3: note: some parts of macro expansion are not guarded by this 'if' clause
  386 |   if (StmtStr)
      |   ^~

ma_error.h:163:3: warning: macro expands to multiple statements [-Wmultistatement-macros]
  163 |   strcpy_s((a)->SqlState, SQL_SQLSTATE_SIZE+1, MADB_ErrorList[MADB_ERR_00000].SqlState); \
      |   ^~~~~~~~
ma_platform_posix.c:256:5: note: in expansion of macro 'MADB_CLEAR_ERROR'
  256 |     MADB_CLEAR_ERROR(Error);
      |     ^~~~~~~~~~~~~~~~
ma_platform_posix.c:255:3: note: some parts of macro expansion are not guarded by this 'if' clause
  255 |   if (Error)
      |   ^~
  • Loading branch information
AdamMajer authored and lawrinn committed Oct 12, 2020
1 parent d56ab33 commit fc3b2fc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions ma_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,13 @@ SQLRETURN MADB_GetDiagField(SQLSMALLINT HandleType, SQLHANDLE Handle,
DiagInfoPtr, SQLSMALLINT BufferLength,
SQLSMALLINT *StringLengthPtr, my_bool isWChar);

#define MADB_CLEAR_ERROR(a) \
#define MADB_CLEAR_ERROR(a) do { \
strcpy_s((a)->SqlState, SQL_SQLSTATE_SIZE+1, MADB_ErrorList[MADB_ERR_00000].SqlState); \
(a)->SqlErrorMsg[(a)->PrefixLen]= 0; \
(a)->NativeError= 0;\
(a)->ReturnValue= SQL_SUCCESS;\
(a)->ErrorNum= 0;
(a)->ErrorNum= 0; \
} while (0)

#define MADB_CLEAR_HANDLE_ERROR(handle_type, handle) \
switch (handle_type) { \
Expand Down
6 changes: 4 additions & 2 deletions ma_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,11 @@ extern my_bool DummyError;

#define BUFFER_CHAR_LEN(blen,wchar) (wchar) ? (blen) / sizeof(SQLWCHAR) : (blen)

#define MADB_FREE(a) \
#define MADB_FREE(a) do { \
free((a));\
(a)= NULL;
(a)= NULL; \
} while(0)

#define MADB_ALLOC(a) malloc((a))
#define MADB_CALLOC(a) calloc((a) > 0 ? (a) : 1, sizeof(char))
#define MADB_REALLOC(a,b) realloc((a),(b))
Expand Down

0 comments on commit fc3b2fc

Please sign in to comment.