From: Tom Lane Date: Tue, 28 Mar 2017 17:16:19 +0000 (-0400) Subject: Suppress implicit-conversion warnings seen with newer clang versions. X-Git-Tag: REL_10_BETA1~465 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8cfeaecfc76a7366b336272bc76e96e09281b133;p=postgresql Suppress implicit-conversion warnings seen with newer clang versions. We were assigning values near 255 through "char *" pointers. On machines where char is signed, that's not entirely kosher, and it's reasonable for compilers to warn about it. A better solution would be to change the pointer type to "unsigned char *", but that would be vastly more invasive. For the moment, let's just apply this simple backpatchable solution. Aleksander Alekseev Discussion: https://postgr.es/m/20170220141239.GD12278@e733.localdomain Discussion: https://postgr.es/m/2839.1490714708@sss.pgh.pa.us --- diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 61ca81d1d2..25fa5443de 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -5044,7 +5044,7 @@ BootStrapXLOG(void) record->xl_rmid = RM_XLOG_ID; recptr += SizeOfXLogRecord; /* fill the XLogRecordDataHeaderShort struct */ - *(recptr++) = XLR_BLOCK_ID_DATA_SHORT; + *(recptr++) = (char) XLR_BLOCK_ID_DATA_SHORT; *(recptr++) = sizeof(checkPoint); memcpy(recptr, &checkPoint, sizeof(checkPoint)); recptr += sizeof(checkPoint); diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index 03b05f937f..a3bd0b7f51 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -739,7 +739,7 @@ XLogRecordAssemble(RmgrId rmid, uint8 info, if ((curinsert_flags & XLOG_INCLUDE_ORIGIN) && replorigin_session_origin != InvalidRepOriginId) { - *(scratch++) = XLR_BLOCK_ID_ORIGIN; + *(scratch++) = (char) XLR_BLOCK_ID_ORIGIN; memcpy(scratch, &replorigin_session_origin, sizeof(replorigin_session_origin)); scratch += sizeof(replorigin_session_origin); } @@ -749,13 +749,13 @@ XLogRecordAssemble(RmgrId rmid, uint8 info, { if (mainrdata_len > 255) { - *(scratch++) = XLR_BLOCK_ID_DATA_LONG; + *(scratch++) = (char) XLR_BLOCK_ID_DATA_LONG; memcpy(scratch, &mainrdata_len, sizeof(uint32)); scratch += sizeof(uint32); } else { - *(scratch++) = XLR_BLOCK_ID_DATA_SHORT; + *(scratch++) = (char) XLR_BLOCK_ID_DATA_SHORT; *(scratch++) = (uint8) mainrdata_len; } rdt_datas_last->next = mainrdata_head; diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c index 27bd9b04e7..bcb9ed938f 100644 --- a/src/bin/pg_resetwal/pg_resetwal.c +++ b/src/bin/pg_resetwal/pg_resetwal.c @@ -1095,7 +1095,7 @@ WriteEmptyXLOG(void) record->xl_rmid = RM_XLOG_ID; recptr += SizeOfXLogRecord; - *(recptr++) = XLR_BLOCK_ID_DATA_SHORT; + *(recptr++) = (char) XLR_BLOCK_ID_DATA_SHORT; *(recptr++) = sizeof(CheckPoint); memcpy(recptr, &ControlFile.checkPointCopy, sizeof(CheckPoint));