]> granicus.if.org Git - postgresql/commitdiff
Suppress implicit-conversion warnings seen with newer clang versions.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 28 Mar 2017 17:16:19 +0000 (13:16 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 28 Mar 2017 17:16:19 +0000 (13:16 -0400)
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

src/backend/access/transam/xlog.c
src/backend/access/transam/xloginsert.c
src/bin/pg_resetxlog/pg_resetxlog.c

index 0f2536d3e25dc563b15f4bb335031ab5e9400e1d..184ea2d4b9e589a77dd0ac03f2c7be329824a1e7 100644 (file)
@@ -4878,7 +4878,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);
index 3cd273b19f2c26e15fc439a782cbf9110a2b3024..a92534e2256f2fb7051f048fe4673858155a89dd 100644 (file)
@@ -703,7 +703,7 @@ XLogRecordAssemble(RmgrId rmid, uint8 info,
        /* followed by the record's origin, if any */
        if (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);
        }
@@ -713,13 +713,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;
index 525b82ba7a77be18a19e1076f88a7dc72af516ce..013c26bd6d2ea9863bc84ff30dd99a05ed94db63 100644 (file)
@@ -1100,7 +1100,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));