aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qemu-error.c1
-rw-r--r--qemu-error.h9
-rw-r--r--qemu-io.c2
-rw-r--r--qemu-malloc.c24
-rw-r--r--qemu-option.c13
-rw-r--r--qemu-sockets.c4
6 files changed, 25 insertions, 28 deletions
diff --git a/qemu-error.c b/qemu-error.c
index 5a35e7c..41c191d 100644
--- a/qemu-error.c
+++ b/qemu-error.c
@@ -12,7 +12,6 @@
#include <stdio.h>
#include "monitor.h"
-#include "sysemu.h"
/*
* Print to current monitor if we have one, else to stderr.
diff --git a/qemu-error.h b/qemu-error.h
index a45609f..4d5c537 100644
--- a/qemu-error.h
+++ b/qemu-error.h
@@ -30,12 +30,11 @@ void loc_set_none(void);
void loc_set_cmdline(char **argv, int idx, int cnt);
void loc_set_file(const char *fname, int lno);
-void error_vprintf(const char *fmt, va_list ap);
-void error_printf(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
-void error_printf_unless_qmp(const char *fmt, ...)
- __attribute__ ((format(printf, 1, 2)));
+void error_vprintf(const char *fmt, va_list ap) GCC_FMT_ATTR(1, 0);
+void error_printf(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
+void error_printf_unless_qmp(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
void error_print_loc(void);
void error_set_progname(const char *argv0);
-void error_report(const char *fmt, ...) __attribute__ ((format(printf, 1, 2)));
+void error_report(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
#endif
diff --git a/qemu-io.c b/qemu-io.c
index f411f34..376b0ab 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -61,7 +61,7 @@ static void *qemu_io_alloc(size_t len, int pattern)
if (misalign)
len += MISALIGN_OFFSET;
- buf = qemu_memalign(512, len);
+ buf = qemu_blockalign(bs, len);
memset(buf, pattern, len);
if (misalign)
buf += MISALIGN_OFFSET;
diff --git a/qemu-malloc.c b/qemu-malloc.c
index 36b0b36..8749fc8 100644
--- a/qemu-malloc.c
+++ b/qemu-malloc.c
@@ -24,16 +24,9 @@
#include "qemu-common.h"
#include <stdlib.h>
-static void *oom_check(void *ptr)
-{
- if (ptr == NULL) {
- abort();
- }
- return ptr;
-}
-
void qemu_free(void *ptr)
{
+ //trace_qemu_free(ptr);
free(ptr);
}
@@ -48,26 +41,35 @@ static int allow_zero_malloc(void)
void *qemu_malloc(size_t size)
{
+ void *ptr;
if (!size && !allow_zero_malloc()) {
abort();
}
- return oom_check(malloc(size ? size : 1));
+ ptr = qemu_oom_check(malloc(size ? size : 1));
+ //trace_qemu_malloc(size, ptr);
+ return ptr;
}
void *qemu_realloc(void *ptr, size_t size)
{
+ void *newptr;
if (!size && !allow_zero_malloc()) {
abort();
}
- return oom_check(realloc(ptr, size ? size : 1));
+ newptr = qemu_oom_check(realloc(ptr, size ? size : 1));
+ //trace_qemu_realloc(ptr, size, newptr);
+ return newptr;
}
void *qemu_mallocz(size_t size)
{
+ void *ptr;
if (!size && !allow_zero_malloc()) {
abort();
}
- return oom_check(calloc(1, size ? size : 1));
+ ptr = qemu_oom_check(calloc(1, size ? size : 1));
+ //trace_qemu_malloc(size, ptr);
+ return ptr;
}
char *qemu_strdup(const char *str)
diff --git a/qemu-option.c b/qemu-option.c
index 1f8f41a..65db542 100644
--- a/qemu-option.c
+++ b/qemu-option.c
@@ -394,8 +394,8 @@ QEMUOptionParameter *append_option_parameters(QEMUOptionParameter *dest,
/*
* Parses a parameter string (param) into an option list (dest).
*
- * list is the templace is. If dest is NULL, a new copy of list is created for
- * it. If list is NULL, this function fails.
+ * list is the template option list. If dest is NULL, a new copy of list is
+ * created. If list is NULL, this function fails.
*
* A parameter string consists of one or more parameters, separated by commas.
* Each parameter consists of its name and possibly of a value. In the latter
@@ -416,20 +416,13 @@ QEMUOptionParameter *parse_option_parameters(const char *param,
char value[256];
char *param_delim, *value_delim;
char next_delim;
- size_t num_options;
if (list == NULL) {
return NULL;
}
if (dest == NULL) {
- // Count valid options
- num_options = count_option_parameters(list);
-
- // Create a copy of the option list to fill in values
- dest = qemu_mallocz((num_options + 1) * sizeof(QEMUOptionParameter));
- allocated = dest;
- memcpy(dest, list, (num_options + 1) * sizeof(QEMUOptionParameter));
+ dest = allocated = append_option_parameters(NULL, list);
}
while (*param) {
diff --git a/qemu-sockets.c b/qemu-sockets.c
index c4c0f65..13c0b93 100644
--- a/qemu-sockets.c
+++ b/qemu-sockets.c
@@ -665,24 +665,28 @@ int unix_connect(const char *path)
int unix_listen_opts(QemuOpts *opts)
{
fprintf(stderr, "unix sockets are not available on windows\n");
+ errno = ENOTSUP;
return -1;
}
int unix_connect_opts(QemuOpts *opts)
{
fprintf(stderr, "unix sockets are not available on windows\n");
+ errno = ENOTSUP;
return -1;
}
int unix_listen(const char *path, char *ostr, int olen)
{
fprintf(stderr, "unix sockets are not available on windows\n");
+ errno = ENOTSUP;
return -1;
}
int unix_connect(const char *path)
{
fprintf(stderr, "unix sockets are not available on windows\n");
+ errno = ENOTSUP;
return -1;
}