summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2017-05-31 15:27:21 +0000
committerTom Lane2017-05-31 15:27:21 +0000
commitb5b322914100f7526c29c92f88c294a0ae5e7dfd (patch)
treed7f9dd4b46ba053b005b83ce4740dadb29a0ffe4
parent54e839fe29c1d071f5129eb4a112546197ea0522 (diff)
Avoid -Wconversion warnings from direct use of GET_n_BYTES macros.
The GET/SET_n_BYTES macros are meant to be infrastructure for the DatumGetFoo/FooGetDatum macros, which include a cast to the intended target type. Using them directly without a cast, as DatumGetFloat4 and friends previously did, can yield warnings when -Wconversion is on. This is of little significance when building Postgres proper, because there are such a huge number of such warnings in the server that nobody would think -Wconversion is of any use. But some extensions build with -Wconversion due to outside constraints. Commit 14cca1bf8 did a disservice to those extensions by moving DatumGetFloat4 et al into postgres.h, where they can now cause warnings in extension builds. To fix, use DatumGetInt32 and friends in place of the low-level macros. This is arguably a bit cleaner anyway. Chapman Flack Discussion: https://postgr.es/m/[email protected]
-rw-r--r--src/include/postgres.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/include/postgres.h b/src/include/postgres.h
index f3582d5523..009337d268 100644
--- a/src/include/postgres.h
+++ b/src/include/postgres.h
@@ -679,7 +679,7 @@ DatumGetFloat4(Datum X)
float4 retval;
} myunion;
- myunion.value = GET_4_BYTES(X);
+ myunion.value = DatumGetInt32(X);
return myunion.retval;
}
#else
@@ -704,7 +704,7 @@ Float4GetDatum(float4 X)
} myunion;
myunion.value = X;
- return SET_4_BYTES(myunion.retval);
+ return Int32GetDatum(myunion.retval);
}
#else
extern Datum Float4GetDatum(float4 X);
@@ -727,7 +727,7 @@ DatumGetFloat8(Datum X)
float8 retval;
} myunion;
- myunion.value = GET_8_BYTES(X);
+ myunion.value = DatumGetInt64(X);
return myunion.retval;
}
#else
@@ -753,7 +753,7 @@ Float8GetDatum(float8 X)
} myunion;
myunion.value = X;
- return SET_8_BYTES(myunion.retval);
+ return Int64GetDatum(myunion.retval);
}
#else
extern Datum Float8GetDatum(float8 X);