mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 14:25:49 +00:00
criu/img-remote.c: use xmalloc
1. Use xmalloc() where possible. 2. There is no need to print an error message, as xmalloc() has already printed it for you. Cc: Rodrigo Bruno <rbruno@gsd.inesc-id.pt> Signed-off-by: Kir Kolyshkin <kir@openvz.org> Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
committed by
Andrei Vagin
parent
47b5489548
commit
ae845f0079
@@ -33,12 +33,11 @@ struct snapshot {
|
||||
|
||||
struct snapshot *new_snapshot(char *snapshot_id)
|
||||
{
|
||||
struct snapshot *s = malloc(sizeof(struct snapshot));
|
||||
struct snapshot *s = xmalloc(sizeof(struct snapshot));
|
||||
|
||||
if (!s) {
|
||||
pr_perror("Failed to allocate snapshot structure");
|
||||
if (!s)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
strncpy(s->snapshot_id, snapshot_id, PATHLEN - 1);
|
||||
s->snapshot_id[PATHLEN - 1]= '\0';
|
||||
return s;
|
||||
@@ -180,7 +179,6 @@ static int pull_snapshot_ids(void)
|
||||
|
||||
s = new_snapshot(ls->snapshot_id);
|
||||
if (!s) {
|
||||
pr_perror("Unable create new snapshot structure");
|
||||
close(sockfd);
|
||||
return -1;
|
||||
}
|
||||
@@ -206,7 +204,6 @@ int push_snapshot_id(void)
|
||||
|
||||
rn.snapshot_id = xmalloc(sizeof(char) * PATHLEN);
|
||||
if (!rn.snapshot_id) {
|
||||
pr_perror("Unable to allocate snapshot id buffer");
|
||||
close(sockfd);
|
||||
return -1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user