postgres.git / summary / log / commit / refs

commit    ef75508efc789c79c5a5d4acd7ad5da85f1e4f08
Author:   Tom Lane <tgl@sss.pgh.pa.us>
Date:     Sun Mar 08 17:58:28 2015 +0000
First released in: 9.5.0, 9.3.7, 9.4.2

    Cast to (void *) rather than (int *) when passing int64's to PQfn().
    
    This is a possibly-vain effort to silence a Coverity warning about
    bogus endianness dependency.  The code's fine, because it takes care
    of endianness issues for itself, but Coverity sees an int64 being
    passed to an int* argument and not unreasonably suspects something's
    wrong.  I'm not sure if putting the void* cast in the way will shut it
    up; but it can't hurt and seems better from a documentation standpoint
    anyway, since the pointer is not used as an int* in this code path.
    
    Just for a bit of additional safety, verify that the result length
    is 8 bytes as expected.
    
    Back-patch to 9.3 where the code in question was added.


src/interfaces/libpq/fe-lobj.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/interfaces/libpq/fe-lobj.c b/src/interfaces/libpq/fe-lobj.c index 6eaec4aacdd..ad0bd351094 100644 --- a/src/interfaces/libpq/fe-lobj.c +++ b/src/interfaces/libpq/fe-lobj.c @@ -290,7 +290,7 @@ lo_read(PGconn *conn, int fd, char *buf, size_t len) argv[1].u.integer = (int) len; res = PQfn(conn, conn->lobjfuncs->fn_lo_read, - (int *) buf, &result_len, 0, argv, 2); + (void *) buf, &result_len, 0, argv, 2); if (PQresultStatus(res) == PGRES_COMMAND_OK) { PQclear(res); @@ -441,8 +441,8 @@ lo_lseek64(PGconn *conn, int fd, pg_int64 offset, int whence) argv[2].u.integer = whence; res = PQfn(conn, conn->lobjfuncs->fn_lo_lseek64, - (int *) &retval, &result_len, 0, argv, 3); - if (PQresultStatus(res) == PGRES_COMMAND_OK) + (void *) &retval, &result_len, 0, argv, 3); + if (PQresultStatus(res) == PGRES_COMMAND_OK && result_len == 8) { PQclear(res); return lo_ntoh64(retval); @@ -607,8 +607,8 @@ lo_tell64(PGconn *conn, int fd) argv[0].u.integer = fd; res = PQfn(conn, conn->lobjfuncs->fn_lo_tell64, - (int *) &retval, &result_len, 0, argv, 1); - if (PQresultStatus(res) == PGRES_COMMAND_OK) + (void *) &retval, &result_len, 0, argv, 1); + if (PQresultStatus(res) == PGRES_COMMAND_OK && result_len == 8) { PQclear(res); return lo_ntoh64(retval); [parent: 01cca2c1b1a0]