forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit450ee70
committed
Use libc's snprintf, not sprintf, for special cases in snprintf.c.
snprintf.c has always fallen back on libc's *printf implementationwhen printing pointers (%p) and floats. When this code originated,we were still supporting some platforms that lacked native snprintf,so we used sprintf for that. That's not actually unsafe in our usage,but nonetheless builds on macOS are starting to complain about sprintfbeing unconditionally deprecated; and I wouldn't be surprised if otherplatforms follow suit. There seems little reason to believe that anyplatform supporting C99 wouldn't have standards-compliant snprintf,so let's just use that instead to suppress such warnings.Back-patch to v12, which is where we started to require C99. It'salso where we started to use our snprintf.c everywhere, so thiswouldn't be enough to suppress the warning in older branches anyway--- that is, in older branches these aren't necessarily all ourusages of libc's sprintf. It is enough in v12+ because anydeprecation annotation attached to libc's sprintf won't apply topg_sprintf. (Whether all our usages of pg_sprintf are adequatelysafe is not a matter I intend to address here, but perhaps it coulddo with some review.)Per report from Andres Freund and local testing.Discussion:https://postgr.es/m/20221015211955.q4cwbsfkyk3c4ty3@awork3.anarazel.de1 parent9a95a51 commit450ee70
1 file changed
+7
-7
lines changedLines changed: 7 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
998 | 998 |
| |
999 | 999 |
| |
1000 | 1000 |
| |
1001 |
| - | |
1002 |
| - | |
| 1001 | + | |
| 1002 | + | |
1003 | 1003 |
| |
1004 | 1004 |
| |
1005 | 1005 |
| |
| |||
1149 | 1149 |
| |
1150 | 1150 |
| |
1151 | 1151 |
| |
1152 |
| - | |
| 1152 | + | |
1153 | 1153 |
| |
1154 | 1154 |
| |
1155 | 1155 |
| |
1156 |
| - | |
| 1156 | + | |
1157 | 1157 |
| |
1158 | 1158 |
| |
1159 | 1159 |
| |
| |||
1205 | 1205 |
| |
1206 | 1206 |
| |
1207 | 1207 |
| |
1208 |
| - | |
| 1208 | + | |
1209 | 1209 |
| |
1210 | 1210 |
| |
1211 | 1211 |
| |
1212 | 1212 |
| |
1213 | 1213 |
| |
1214 | 1214 |
| |
1215 |
| - | |
| 1215 | + | |
1216 | 1216 |
| |
1217 | 1217 |
| |
1218 | 1218 |
| |
| |||
1341 | 1341 |
| |
1342 | 1342 |
| |
1343 | 1343 |
| |
1344 |
| - | |
| 1344 | + | |
1345 | 1345 |
| |
1346 | 1346 |
| |
1347 | 1347 |
| |
|
0 commit comments
Comments
(0)