Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 30f35ef

Browse files
author
Thomas G. Lockhart
committed
Test for and handle NULL arguments to mylog() print statements.
Include definition for _IN_ADDR_T if INADDR_NONE is not defined.
1 parent f47bd80 commit 30f35ef

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

src/interfaces/odbc/convert.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ struct tm *tim;
120120
st.d = tim->tm_mday;
121121
st.y = tim->tm_year + 1900;
122122

123-
mylog("copy_and_convert: field_type = %d, fctype = %d, value = '%s', cbValueMax=%d\n", field_type, fCType, value, cbValueMax);
123+
mylog("copy_and_convert: field_type = %d, fctype = %d, value = '%s', cbValueMax=%d\n", field_type, fCType, (value==NULL)?"<NULL>":value, cbValueMax);
124124

125125
if ( ! value) {
126126
/* handle a null just by returning SQL_NULL_DATA in pcbValue, */

src/interfaces/odbc/qresult.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@ QR_fetch_tuples(QResultClass *self, ConnectionClass *conn, char *cursor)
186186
if (conn != NULL) {
187187
self->conn = conn;
188188

189-
mylog("QR_fetch_tuples: cursor = '%s', self->cursor=%u\n", cursor, self->cursor);
189+
mylog("QR_fetch_tuples: cursor = '%s', self->cursor=%u\n",
190+
(cursor==NULL)?"":cursor, self->cursor);
190191

191192
if (self->cursor)
192193
free(self->cursor);

src/interfaces/odbc/results.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,7 +855,7 @@ mylog("SQLFetch: stmt = %u, stmt->result= %u\n", stmt, stmt->result);
855855
value = QR_get_value_backend_row(res, stmt->currTuple, lf);
856856
}
857857

858-
mylog("value = '%s'\n", value);
858+
mylog("value = '%s'\n", (value==NULL)?"<NULL>":value);
859859

860860
retval = copy_and_convert_field_bindinfo(stmt, type, value, lf);
861861

src/interfaces/odbc/socket.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@
2323
#include <arpa/inet.h>
2424
#define closesocket(xxx) close(xxx)
2525
#define SOCKETFD int
26+
#ifndef INADDR_NONE
27+
#ifndef _IN_ADDR_T
28+
#define _IN_ADDR_T
29+
typedef unsigned int in_addr_t;
30+
#endif
31+
#define INADDR_NONE ((in_addr_t)-1)
32+
#endif
2633
#else
2734
#include <winsock.h>
2835
#define SOCKETFD SOCKET

0 commit comments

Comments
 (0)