mirror of
https://github.com/EnterpriseDB/repmgr.git
synced 2026-03-22 22:56:29 +00:00
Avoid compiler warnings for various strncpy() operations
Here the compiler may complain that the source length is being used, though in all cases the source length was previously used to define the length of the destination buffer, so it's not actually a problem.
This commit is contained in:
@@ -2250,6 +2250,7 @@ print_event_notification_list(EventNotificationList *list)
|
|||||||
PQExpBufferData buf;
|
PQExpBufferData buf;
|
||||||
char *ptr;
|
char *ptr;
|
||||||
EventNotificationListCell *cell;
|
EventNotificationListCell *cell;
|
||||||
|
int ptr_len;
|
||||||
|
|
||||||
initPQExpBuffer(&buf);
|
initPQExpBuffer(&buf);
|
||||||
cell = list->head;
|
cell = list->head;
|
||||||
@@ -2264,8 +2265,10 @@ print_event_notification_list(EventNotificationList *list)
|
|||||||
cell = cell->next;
|
cell = cell->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
ptr = palloc0(strlen(buf.data) + 1);
|
ptr_len = strlen(buf.data);
|
||||||
strncpy(ptr, buf.data, strlen(buf.data));
|
ptr = palloc0(ptr_len + 1);
|
||||||
|
|
||||||
|
strncpy(ptr, buf.data, ptr_len);
|
||||||
|
|
||||||
termPQExpBuffer(&buf);
|
termPQExpBuffer(&buf);
|
||||||
|
|
||||||
|
|||||||
@@ -7789,7 +7789,9 @@ static void
|
|||||||
tablespace_data_append(TablespaceDataList *list, const char *name, const char *oid, const char *location)
|
tablespace_data_append(TablespaceDataList *list, const char *name, const char *oid, const char *location)
|
||||||
{
|
{
|
||||||
TablespaceDataListCell *cell = NULL;
|
TablespaceDataListCell *cell = NULL;
|
||||||
|
int oid_len = strlen(oid);
|
||||||
|
int name_len = strlen(name);
|
||||||
|
int location_len = strlen(location);
|
||||||
cell = (TablespaceDataListCell *) pg_malloc0(sizeof(TablespaceDataListCell));
|
cell = (TablespaceDataListCell *) pg_malloc0(sizeof(TablespaceDataListCell));
|
||||||
|
|
||||||
if (cell == NULL)
|
if (cell == NULL)
|
||||||
@@ -7798,13 +7800,13 @@ tablespace_data_append(TablespaceDataList *list, const char *name, const char *o
|
|||||||
exit(ERR_OUT_OF_MEMORY);
|
exit(ERR_OUT_OF_MEMORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
cell->oid = pg_malloc(1 + strlen(oid));
|
cell->oid = pg_malloc0(1 + oid_len);
|
||||||
cell->name = pg_malloc(1 + strlen(name));
|
cell->name = pg_malloc0(1 + name_len);
|
||||||
cell->location = pg_malloc(1 + strlen(location));
|
cell->location = pg_malloc0(1 + location_len);
|
||||||
|
|
||||||
strncpy(cell->oid, oid, 1 + strlen(oid));
|
strncpy(cell->oid, oid, oid_len);
|
||||||
strncpy(cell->name, name, 1 + strlen(name));
|
strncpy(cell->name, name, name_len);
|
||||||
strncpy(cell->location, location, 1 + strlen(location));
|
strncpy(cell->location, location, location_len);
|
||||||
|
|
||||||
if (list->tail)
|
if (list->tail)
|
||||||
list->tail->next = cell;
|
list->tail->next = cell;
|
||||||
|
|||||||
Reference in New Issue
Block a user