mirror of
https://github.com/postgres/postgres.git
synced 2025-06-25 01:02:05 +03:00
Replace remaining StrNCpy() by strlcpy()
They are equivalent, except that StrNCpy() zero-fills the entire destination buffer instead of providing just one trailing zero. For all but a tiny number of callers, that's just overhead rather than being desirable. Remove StrNCpy() as it is now unused. In some cases, namestrcpy() is the more appropriate function to use. While we're here, simplify the API of namestrcpy(): Remove the return value, don't check for NULL input. Nothing was using that anyway. Also, remove a few unused name-related functions. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://www.postgresql.org/message-id/flat/44f5e198-36f6-6cdb-7fa9-60e34784daae%402ndquadrant.com
This commit is contained in:
@ -1015,7 +1015,7 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm *tm, char **tzn)
|
||||
* Copy no more than MAXTZLEN bytes of timezone to tzn, in case it
|
||||
* contains an error message, which doesn't fit in the buffer
|
||||
*/
|
||||
StrNCpy(*tzn, tm->tm_zone, MAXTZLEN + 1);
|
||||
strlcpy(*tzn, tm->tm_zone, MAXTZLEN + 1);
|
||||
if (strlen(tm->tm_zone) > MAXTZLEN)
|
||||
tm->tm_isdst = -1;
|
||||
}
|
||||
@ -1033,7 +1033,7 @@ abstime2tm(AbsoluteTime _time, int *tzp, struct tm *tm, char **tzn)
|
||||
* Copy no more than MAXTZLEN bytes of timezone to tzn, in case it
|
||||
* contains an error message, which doesn't fit in the buffer
|
||||
*/
|
||||
StrNCpy(*tzn, TZNAME_GLOBAL[tm->tm_isdst], MAXTZLEN + 1);
|
||||
strlcpy(*tzn, TZNAME_GLOBAL[tm->tm_isdst], MAXTZLEN + 1);
|
||||
if (strlen(TZNAME_GLOBAL[tm->tm_isdst]) > MAXTZLEN)
|
||||
tm->tm_isdst = -1;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ ecpg_filter(const char *sourcefile, const char *outfile)
|
||||
if (plen > 1)
|
||||
{
|
||||
n = (char *) malloc(plen);
|
||||
StrNCpy(n, p + 1, plen);
|
||||
strlcpy(n, p + 1, plen);
|
||||
replace_string(linebuf, n, "");
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user