mirror of
https://gitlab.com/apparmor/apparmor
synced 2025-08-30 22:05:27 +00:00
cleanup asprintf return value being ignored warnings
This commit is contained in:
@@ -786,21 +786,24 @@ int cache_fd = -1;
|
||||
int sd_serialize_codomain(int option, struct codomain *cod)
|
||||
{
|
||||
int fd;
|
||||
int error = 0, size, wsize;
|
||||
int error = -ENOMEM, size, wsize;
|
||||
sd_serialize *work_area;
|
||||
char *filename = NULL;
|
||||
|
||||
switch (option) {
|
||||
case OPTION_ADD:
|
||||
asprintf(&filename, "%s/.load", subdomainbase);
|
||||
if (asprintf(&filename, "%s/.load", subdomainbase) == -1)
|
||||
goto exit;
|
||||
fd = open(filename, O_WRONLY);
|
||||
break;
|
||||
case OPTION_REPLACE:
|
||||
asprintf(&filename, "%s/.replace", subdomainbase);
|
||||
if (asprintf(&filename, "%s/.replace", subdomainbase) == -1)
|
||||
goto exit;
|
||||
fd = open(filename, O_WRONLY);
|
||||
break;
|
||||
case OPTION_REMOVE:
|
||||
asprintf(&filename, "%s/.remove", subdomainbase);
|
||||
if (asprintf(&filename, "%s/.remove", subdomainbase) == -1)
|
||||
goto exit;
|
||||
fd = open(filename, O_WRONLY);
|
||||
break;
|
||||
case OPTION_STDOUT:
|
||||
@@ -820,6 +823,8 @@ int sd_serialize_codomain(int option, struct codomain *cod)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
error = 0;
|
||||
|
||||
if (option != OPTION_STDOUT)
|
||||
free(filename);
|
||||
|
||||
@@ -938,17 +943,19 @@ static char *next_profile_buffer(char *buffer, int size)
|
||||
int sd_load_buffer(int option, char *buffer, int size)
|
||||
{
|
||||
int fd;
|
||||
int error = 0, wsize, bsize;
|
||||
int error = -ENOMEM, wsize, bsize;
|
||||
char *filename = NULL;
|
||||
char *b;
|
||||
|
||||
switch (option) {
|
||||
case OPTION_ADD:
|
||||
asprintf(&filename, "%s/.load", subdomainbase);
|
||||
if (asprintf(&filename, "%s/.load", subdomainbase) == -1)
|
||||
goto exit;
|
||||
fd = open(filename, O_WRONLY);
|
||||
break;
|
||||
case OPTION_REPLACE:
|
||||
asprintf(&filename, "%s/.replace", subdomainbase);
|
||||
if (asprintf(&filename, "%s/.replace", subdomainbase) == -1)
|
||||
goto exit;
|
||||
fd = open(filename, O_WRONLY);
|
||||
break;
|
||||
default:
|
||||
@@ -964,6 +971,7 @@ int sd_load_buffer(int option, char *buffer, int size)
|
||||
goto exit;
|
||||
}
|
||||
|
||||
error = 0;
|
||||
for (b = buffer; b ; b = next_profile_buffer(b + sizeof(header_version), bsize)) {
|
||||
bsize = size - (b - buffer);
|
||||
wsize = write(fd, b, bsize);
|
||||
|
Reference in New Issue
Block a user