* [Qemu-trivial] [PULL 00/23] Trivial patches for 2014-05-26
@ 2014-05-26 7:19 ` Michael Tokarev
0 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:19 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev
Here's another trivial patches pull request.
This time it accumulated 23 patches, in many areas, with a focus,
for some reason, on libcacard, which received quite some cleanups
and a fix for a fun bug.
More interesting changes this time are by Peter Maydell, -- these
are the bswap.h macros renaming and using a subdir in curdir for
temporaries.
Please consider applying.
/mjt
The following changes since commit 6054d883d6138bfc92c73a7c090c824b64086fd2:
Merge remote-tracking branch 'remotes/kraxel/tags/pull-chardev-2' into staging (2014-05-22 18:14:01 +0100)
are available in the git repository at:
git://git.corpit.ru/qemu.git tags/trivial-patches-2014-05-26
for you to fetch changes up to 1687a089f103f9b7a1b4a1555068054cb46ee9e9:
libcacard: remove useless initializers (2014-05-26 10:41:22 +0400)
----------------------------------------------------------------
trivial patches for 2014-05-26
----------------------------------------------------------------
Dr. David Alan Gilbert (1):
vl: fix 'name' option to work with -readconfig
Hani Benhabiles (2):
nbd: Close socket on negotiation failure.
nbd: Miscellaneous typo fixes.
Jules Wang (1):
dma-helpers: avoid calling dma_bdrv_unmap() twice
Le Tan (3):
arch_init: replace fprintf(stderr, ...) with error_report()
audio: replace fprintf(stderr, ...) with error_report() in audio
bsd-user: replace fprintf(stderr, ...) with error_report()
Markus Armbruster (6):
libcacard/vscclient: Bury some dead code
libcacard: Plug memory leaks around vreader_get_reader_list()
libcacard/vreader: Drop broken recovery from failed assertion
libcacard/vreader: Tighten assertion to clarify intent
libcacard: Convert two leftover realloc() to GLib
libcacard/vcard_emul_nss: Drop a redundant conditional
Michael Tokarev (3):
libcacard: g_malloc cleanups
libcacard: fix wrong array expansion logic
libcacard: remove useless initializers
Peter Crosthwaite (1):
net: cadence_gem: Fix top comment
Peter Maydell (3):
iohandler.c: Properly initialize sigaction struct
bswap.h: Rename ldl_p, stl_p, etc to ldl_he_p, stl_he_p, etc
configure: Put tempfiles in a subdir of the build directory
Saravanakumar (2):
jazz_led: Add missing break in switch case
pci: move dereferencing of root only after verifying valid root pointer
Stefan Weil (1):
configure: Automatically select GTK+ 3.0 if GTK+ 2.0 is unavailable
.gitignore | 1 +
arch_init.c | 32 +++++++++++++--------------
audio/spiceaudio.c | 2 +-
audio/wavcapture.c | 3 +--
blockdev-nbd.c | 4 ++--
bsd-user/bsdload.c | 2 +-
bsd-user/elfload.c | 2 +-
bsd-user/main.c | 14 ++++++------
configure | 51 ++++++++++++++++++++++++++++++--------------
dma-helpers.c | 2 +-
hw/display/jazz_led.c | 1 +
hw/net/cadence_gem.c | 2 +-
hw/pci/pci.c | 4 ++--
include/qemu/bswap.h | 45 +++++++++++++++++++-------------------
iohandler.c | 1 +
libcacard/cac.c | 38 +++++++++++----------------------
libcacard/card_7816.c | 16 ++++++--------
libcacard/event.c | 2 +-
libcacard/vcard.c | 26 ++++++----------------
libcacard/vcard_emul_nss.c | 39 +++++++++++++++------------------
libcacard/vreader.c | 31 +++++++++++----------------
libcacard/vscclient.c | 11 +++++-----
nbd.c | 2 +-
qemu-nbd.c | 6 ++++--
qemu-nbd.texi | 2 +-
vl.c | 9 ++++++--
26 files changed, 167 insertions(+), 181 deletions(-)
^ permalink raw reply [flat|nested] 58+ messages in thread
* [Qemu-devel] [PULL 00/23] Trivial patches for 2014-05-26
@ 2014-05-26 7:19 ` Michael Tokarev
0 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:19 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev
Here's another trivial patches pull request.
This time it accumulated 23 patches, in many areas, with a focus,
for some reason, on libcacard, which received quite some cleanups
and a fix for a fun bug.
More interesting changes this time are by Peter Maydell, -- these
are the bswap.h macros renaming and using a subdir in curdir for
temporaries.
Please consider applying.
/mjt
The following changes since commit 6054d883d6138bfc92c73a7c090c824b64086fd2:
Merge remote-tracking branch 'remotes/kraxel/tags/pull-chardev-2' into staging (2014-05-22 18:14:01 +0100)
are available in the git repository at:
git://git.corpit.ru/qemu.git tags/trivial-patches-2014-05-26
for you to fetch changes up to 1687a089f103f9b7a1b4a1555068054cb46ee9e9:
libcacard: remove useless initializers (2014-05-26 10:41:22 +0400)
----------------------------------------------------------------
trivial patches for 2014-05-26
----------------------------------------------------------------
Dr. David Alan Gilbert (1):
vl: fix 'name' option to work with -readconfig
Hani Benhabiles (2):
nbd: Close socket on negotiation failure.
nbd: Miscellaneous typo fixes.
Jules Wang (1):
dma-helpers: avoid calling dma_bdrv_unmap() twice
Le Tan (3):
arch_init: replace fprintf(stderr, ...) with error_report()
audio: replace fprintf(stderr, ...) with error_report() in audio
bsd-user: replace fprintf(stderr, ...) with error_report()
Markus Armbruster (6):
libcacard/vscclient: Bury some dead code
libcacard: Plug memory leaks around vreader_get_reader_list()
libcacard/vreader: Drop broken recovery from failed assertion
libcacard/vreader: Tighten assertion to clarify intent
libcacard: Convert two leftover realloc() to GLib
libcacard/vcard_emul_nss: Drop a redundant conditional
Michael Tokarev (3):
libcacard: g_malloc cleanups
libcacard: fix wrong array expansion logic
libcacard: remove useless initializers
Peter Crosthwaite (1):
net: cadence_gem: Fix top comment
Peter Maydell (3):
iohandler.c: Properly initialize sigaction struct
bswap.h: Rename ldl_p, stl_p, etc to ldl_he_p, stl_he_p, etc
configure: Put tempfiles in a subdir of the build directory
Saravanakumar (2):
jazz_led: Add missing break in switch case
pci: move dereferencing of root only after verifying valid root pointer
Stefan Weil (1):
configure: Automatically select GTK+ 3.0 if GTK+ 2.0 is unavailable
.gitignore | 1 +
arch_init.c | 32 +++++++++++++--------------
audio/spiceaudio.c | 2 +-
audio/wavcapture.c | 3 +--
blockdev-nbd.c | 4 ++--
bsd-user/bsdload.c | 2 +-
bsd-user/elfload.c | 2 +-
bsd-user/main.c | 14 ++++++------
configure | 51 ++++++++++++++++++++++++++++++--------------
dma-helpers.c | 2 +-
hw/display/jazz_led.c | 1 +
hw/net/cadence_gem.c | 2 +-
hw/pci/pci.c | 4 ++--
include/qemu/bswap.h | 45 +++++++++++++++++++-------------------
iohandler.c | 1 +
libcacard/cac.c | 38 +++++++++++----------------------
libcacard/card_7816.c | 16 ++++++--------
libcacard/event.c | 2 +-
libcacard/vcard.c | 26 ++++++----------------
libcacard/vcard_emul_nss.c | 39 +++++++++++++++------------------
libcacard/vreader.c | 31 +++++++++++----------------
libcacard/vscclient.c | 11 +++++-----
nbd.c | 2 +-
qemu-nbd.c | 6 ++++--
qemu-nbd.texi | 2 +-
vl.c | 9 ++++++--
26 files changed, 167 insertions(+), 181 deletions(-)
^ permalink raw reply [flat|nested] 58+ messages in thread
* [Qemu-trivial] [PULL 01/23] libcacard: g_malloc cleanups
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
@ 2014-05-26 7:19 ` Michael Tokarev
-1 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:19 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev
This patch replaces g_malloc() in libcacard into g_new()
or g_new0() where appropriate (removing some init-to-zero
surrounding code), g_malloc+memcpy into g_memdup() and the
like.
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Alon Levy <alevy@redhat.com>
---
libcacard/cac.c | 11 +++--------
libcacard/card_7816.c | 11 +++++------
libcacard/event.c | 2 +-
libcacard/vcard.c | 22 +++++-----------------
libcacard/vcard_emul_nss.c | 12 ++++++------
libcacard/vreader.c | 11 +++--------
6 files changed, 23 insertions(+), 46 deletions(-)
diff --git a/libcacard/cac.c b/libcacard/cac.c
index 74ef3e3..122129e 100644
--- a/libcacard/cac.c
+++ b/libcacard/cac.c
@@ -310,16 +310,11 @@ static VCardAppletPrivate *
cac_new_pki_applet_private(const unsigned char *cert,
int cert_len, VCardKey *key)
{
- CACPKIAppletData *pki_applet_data = NULL;
- VCardAppletPrivate *applet_private = NULL;
- applet_private = (VCardAppletPrivate *)g_malloc(sizeof(VCardAppletPrivate));
+ CACPKIAppletData *pki_applet_data;
+ VCardAppletPrivate *applet_private;
+ applet_private = g_new0(VCardAppletPrivate, 1);
pki_applet_data = &(applet_private->u.pki_data);
- pki_applet_data->cert_buffer = NULL;
- pki_applet_data->cert_buffer_len = 0;
- pki_applet_data->sign_buffer = NULL;
- pki_applet_data->sign_buffer_len = 0;
- pki_applet_data->key = NULL;
pki_applet_data->cert = (unsigned char *)g_malloc(cert_len+1);
/*
* if we want to support compression, then we simply change the 0 to a 1
diff --git a/libcacard/card_7816.c b/libcacard/card_7816.c
index c28bb60..bca8c4a 100644
--- a/libcacard/card_7816.c
+++ b/libcacard/card_7816.c
@@ -51,7 +51,7 @@ vcard_response_new_data(unsigned char *buf, int len)
{
VCardResponse *new_response;
- new_response = (VCardResponse *)g_malloc(sizeof(VCardResponse));
+ new_response = g_new(VCardResponse, 1);
new_response->b_data = g_malloc(len + 2);
memcpy(new_response->b_data, buf, len);
new_response->b_total_len = len+2;
@@ -132,7 +132,7 @@ vcard_response_new_status(vcard_7816_status_t status)
{
VCardResponse *new_response;
- new_response = (VCardResponse *)g_malloc(sizeof(VCardResponse));
+ new_response = g_new(VCardResponse, 1);
new_response->b_data = &new_response->b_sw1;
new_response->b_len = 0;
new_response->b_total_len = 2;
@@ -149,7 +149,7 @@ vcard_response_new_status_bytes(unsigned char sw1, unsigned char sw2)
{
VCardResponse *new_response;
- new_response = (VCardResponse *)g_malloc(sizeof(VCardResponse));
+ new_response = g_new(VCardResponse, 1);
new_response->b_data = &new_response->b_sw1;
new_response->b_len = 0;
new_response->b_total_len = 2;
@@ -336,9 +336,8 @@ vcard_apdu_new(unsigned char *raw_apdu, int len, vcard_7816_status_t *status)
return NULL;
}
- new_apdu = (VCardAPDU *)g_malloc(sizeof(VCardAPDU));
- new_apdu->a_data = g_malloc(len);
- memcpy(new_apdu->a_data, raw_apdu, len);
+ new_apdu = g_new(VCardAPDU, 1);
+ new_apdu->a_data = g_memdup(raw_apdu, len);
new_apdu->a_len = len;
*status = vcard_apdu_set_class(new_apdu);
if (*status != VCARD7816_STATUS_SUCCESS) {
diff --git a/libcacard/event.c b/libcacard/event.c
index 2d7500f..a2e6c7d 100644
--- a/libcacard/event.c
+++ b/libcacard/event.c
@@ -17,7 +17,7 @@ vevent_new(VEventType type, VReader *reader, VCard *card)
{
VEvent *new_vevent;
- new_vevent = (VEvent *)g_malloc(sizeof(VEvent));
+ new_vevent = g_new(VEvent, 1);
new_vevent->next = NULL;
new_vevent->type = type;
new_vevent->reader = vreader_reference(reader);
diff --git a/libcacard/vcard.c b/libcacard/vcard.c
index 539177b..227e477 100644
--- a/libcacard/vcard.c
+++ b/libcacard/vcard.c
@@ -37,9 +37,8 @@ vcard_buffer_response_new(unsigned char *buffer, int size)
{
VCardBufferResponse *new_buffer;
- new_buffer = (VCardBufferResponse *)g_malloc(sizeof(VCardBufferResponse));
- new_buffer->buffer = (unsigned char *)g_malloc(size);
- memcpy(new_buffer->buffer, buffer, size);
+ new_buffer = g_new(VCardBufferResponse, 1);
+ new_buffer->buffer = (unsigned char *)g_memdup(buffer, size);
new_buffer->buffer_len = size;
new_buffer->current = new_buffer->buffer;
new_buffer->len = size;
@@ -102,15 +101,11 @@ vcard_new_applet(VCardProcessAPDU applet_process_function,
{
VCardApplet *applet;
- applet = (VCardApplet *)g_malloc(sizeof(VCardApplet));
- applet->next = NULL;
- applet->applet_private = NULL;
- applet->applet_private_free = NULL;
+ applet = g_new0(VCardApplet, 1);
applet->process_apdu = applet_process_function;
applet->reset_applet = applet_reset_function;
- applet->aid = g_malloc(aid_len);
- memcpy(applet->aid, aid, aid_len);
+ applet->aid = g_memdup(aid, aid_len);
applet->aid_len = aid_len;
return applet;
}
@@ -149,18 +144,11 @@ VCard *
vcard_new(VCardEmul *private, VCardEmulFree private_free)
{
VCard *new_card;
- int i;
- new_card = (VCard *)g_malloc(sizeof(VCard));
- new_card->applet_list = NULL;
- for (i = 0; i < MAX_CHANNEL; i++) {
- new_card->current_applet[i] = NULL;
- }
- new_card->vcard_buffer_response = NULL;
+ new_card = g_new0(VCard, 1);
new_card->type = VCARD_VM;
new_card->vcard_private = private;
new_card->vcard_private_free = private_free;
- new_card->vcard_get_atr = NULL;
new_card->reference_count = 1;
return new_card;
}
diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c
index e2b196d..75b9d79 100644
--- a/libcacard/vcard_emul_nss.c
+++ b/libcacard/vcard_emul_nss.c
@@ -94,9 +94,9 @@ static void
vcard_emul_alloc_arrays(unsigned char ***certsp, int **cert_lenp,
VCardKey ***keysp, int cert_count)
{
- *certsp = (unsigned char **)g_malloc(sizeof(unsigned char *)*cert_count);
- *cert_lenp = (int *)g_malloc(sizeof(int)*cert_count);
- *keysp = (VCardKey **)g_malloc(sizeof(VCardKey *)*cert_count);
+ *certsp = g_new(unsigned char *, cert_count);
+ *cert_lenp = g_new(int, cert_count);
+ *keysp = g_new(VCardKey *, cert_count);
}
/*
@@ -139,7 +139,7 @@ vcard_emul_make_key(PK11SlotInfo *slot, CERTCertificate *cert)
{
VCardKey *key;
- key = (VCardKey *)g_malloc(sizeof(VCardKey));
+ key = g_new(VCardKey, 1);
key->slot = PK11_ReferenceSlot(slot);
key->cert = CERT_DupCertificate(cert);
/* NOTE: if we aren't logged into the token, this could return NULL */
@@ -449,7 +449,7 @@ vreader_emul_new(PK11SlotInfo *slot, VCardEmulType type, const char *params)
{
VReaderEmul *new_reader_emul;
- new_reader_emul = (VReaderEmul *)g_malloc(sizeof(VReaderEmul));
+ new_reader_emul = g_new(VReaderEmul, 1);
new_reader_emul->slot = PK11_ReferenceSlot(slot);
new_reader_emul->default_type = type;
@@ -1189,7 +1189,7 @@ vcard_emul_options(const char *args)
g_strndup(type_params, type_params_length);
count = count_tokens(args, ',', ')') + 1;
vreaderOpt->cert_count = count;
- vreaderOpt->cert_name = (char **)g_malloc(count*sizeof(char *));
+ vreaderOpt->cert_name = g_new(char *, count);
for (i = 0; i < count; i++) {
const char *cert = args;
args = strpbrk(args, ",)");
diff --git a/libcacard/vreader.c b/libcacard/vreader.c
index 7720295..9304a28 100644
--- a/libcacard/vreader.c
+++ b/libcacard/vreader.c
@@ -115,7 +115,7 @@ vreader_new(const char *name, VReaderEmul *private,
{
VReader *reader;
- reader = (VReader *)g_malloc(sizeof(VReader));
+ reader = g_new(VReader, 1);
qemu_mutex_init(&reader->lock);
reader->reference_count = 1;
reader->name = g_strdup(name);
@@ -312,10 +312,7 @@ vreader_list_entry_new(VReader *reader)
{
VReaderListEntry *new_reader_list_entry;
- new_reader_list_entry = (VReaderListEntry *)
- g_malloc(sizeof(VReaderListEntry));
- new_reader_list_entry->next = NULL;
- new_reader_list_entry->prev = NULL;
+ new_reader_list_entry = g_new0(VReaderListEntry, 1);
new_reader_list_entry->reader = vreader_reference(reader);
return new_reader_list_entry;
}
@@ -336,9 +333,7 @@ vreader_list_new(void)
{
VReaderList *new_reader_list;
- new_reader_list = (VReaderList *)g_malloc(sizeof(VReaderList));
- new_reader_list->head = NULL;
- new_reader_list->tail = NULL;
+ new_reader_list = g_new0(VReaderList, 1);
return new_reader_list;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-devel] [PULL 01/23] libcacard: g_malloc cleanups
@ 2014-05-26 7:19 ` Michael Tokarev
0 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:19 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev
This patch replaces g_malloc() in libcacard into g_new()
or g_new0() where appropriate (removing some init-to-zero
surrounding code), g_malloc+memcpy into g_memdup() and the
like.
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Alon Levy <alevy@redhat.com>
---
libcacard/cac.c | 11 +++--------
libcacard/card_7816.c | 11 +++++------
libcacard/event.c | 2 +-
libcacard/vcard.c | 22 +++++-----------------
libcacard/vcard_emul_nss.c | 12 ++++++------
libcacard/vreader.c | 11 +++--------
6 files changed, 23 insertions(+), 46 deletions(-)
diff --git a/libcacard/cac.c b/libcacard/cac.c
index 74ef3e3..122129e 100644
--- a/libcacard/cac.c
+++ b/libcacard/cac.c
@@ -310,16 +310,11 @@ static VCardAppletPrivate *
cac_new_pki_applet_private(const unsigned char *cert,
int cert_len, VCardKey *key)
{
- CACPKIAppletData *pki_applet_data = NULL;
- VCardAppletPrivate *applet_private = NULL;
- applet_private = (VCardAppletPrivate *)g_malloc(sizeof(VCardAppletPrivate));
+ CACPKIAppletData *pki_applet_data;
+ VCardAppletPrivate *applet_private;
+ applet_private = g_new0(VCardAppletPrivate, 1);
pki_applet_data = &(applet_private->u.pki_data);
- pki_applet_data->cert_buffer = NULL;
- pki_applet_data->cert_buffer_len = 0;
- pki_applet_data->sign_buffer = NULL;
- pki_applet_data->sign_buffer_len = 0;
- pki_applet_data->key = NULL;
pki_applet_data->cert = (unsigned char *)g_malloc(cert_len+1);
/*
* if we want to support compression, then we simply change the 0 to a 1
diff --git a/libcacard/card_7816.c b/libcacard/card_7816.c
index c28bb60..bca8c4a 100644
--- a/libcacard/card_7816.c
+++ b/libcacard/card_7816.c
@@ -51,7 +51,7 @@ vcard_response_new_data(unsigned char *buf, int len)
{
VCardResponse *new_response;
- new_response = (VCardResponse *)g_malloc(sizeof(VCardResponse));
+ new_response = g_new(VCardResponse, 1);
new_response->b_data = g_malloc(len + 2);
memcpy(new_response->b_data, buf, len);
new_response->b_total_len = len+2;
@@ -132,7 +132,7 @@ vcard_response_new_status(vcard_7816_status_t status)
{
VCardResponse *new_response;
- new_response = (VCardResponse *)g_malloc(sizeof(VCardResponse));
+ new_response = g_new(VCardResponse, 1);
new_response->b_data = &new_response->b_sw1;
new_response->b_len = 0;
new_response->b_total_len = 2;
@@ -149,7 +149,7 @@ vcard_response_new_status_bytes(unsigned char sw1, unsigned char sw2)
{
VCardResponse *new_response;
- new_response = (VCardResponse *)g_malloc(sizeof(VCardResponse));
+ new_response = g_new(VCardResponse, 1);
new_response->b_data = &new_response->b_sw1;
new_response->b_len = 0;
new_response->b_total_len = 2;
@@ -336,9 +336,8 @@ vcard_apdu_new(unsigned char *raw_apdu, int len, vcard_7816_status_t *status)
return NULL;
}
- new_apdu = (VCardAPDU *)g_malloc(sizeof(VCardAPDU));
- new_apdu->a_data = g_malloc(len);
- memcpy(new_apdu->a_data, raw_apdu, len);
+ new_apdu = g_new(VCardAPDU, 1);
+ new_apdu->a_data = g_memdup(raw_apdu, len);
new_apdu->a_len = len;
*status = vcard_apdu_set_class(new_apdu);
if (*status != VCARD7816_STATUS_SUCCESS) {
diff --git a/libcacard/event.c b/libcacard/event.c
index 2d7500f..a2e6c7d 100644
--- a/libcacard/event.c
+++ b/libcacard/event.c
@@ -17,7 +17,7 @@ vevent_new(VEventType type, VReader *reader, VCard *card)
{
VEvent *new_vevent;
- new_vevent = (VEvent *)g_malloc(sizeof(VEvent));
+ new_vevent = g_new(VEvent, 1);
new_vevent->next = NULL;
new_vevent->type = type;
new_vevent->reader = vreader_reference(reader);
diff --git a/libcacard/vcard.c b/libcacard/vcard.c
index 539177b..227e477 100644
--- a/libcacard/vcard.c
+++ b/libcacard/vcard.c
@@ -37,9 +37,8 @@ vcard_buffer_response_new(unsigned char *buffer, int size)
{
VCardBufferResponse *new_buffer;
- new_buffer = (VCardBufferResponse *)g_malloc(sizeof(VCardBufferResponse));
- new_buffer->buffer = (unsigned char *)g_malloc(size);
- memcpy(new_buffer->buffer, buffer, size);
+ new_buffer = g_new(VCardBufferResponse, 1);
+ new_buffer->buffer = (unsigned char *)g_memdup(buffer, size);
new_buffer->buffer_len = size;
new_buffer->current = new_buffer->buffer;
new_buffer->len = size;
@@ -102,15 +101,11 @@ vcard_new_applet(VCardProcessAPDU applet_process_function,
{
VCardApplet *applet;
- applet = (VCardApplet *)g_malloc(sizeof(VCardApplet));
- applet->next = NULL;
- applet->applet_private = NULL;
- applet->applet_private_free = NULL;
+ applet = g_new0(VCardApplet, 1);
applet->process_apdu = applet_process_function;
applet->reset_applet = applet_reset_function;
- applet->aid = g_malloc(aid_len);
- memcpy(applet->aid, aid, aid_len);
+ applet->aid = g_memdup(aid, aid_len);
applet->aid_len = aid_len;
return applet;
}
@@ -149,18 +144,11 @@ VCard *
vcard_new(VCardEmul *private, VCardEmulFree private_free)
{
VCard *new_card;
- int i;
- new_card = (VCard *)g_malloc(sizeof(VCard));
- new_card->applet_list = NULL;
- for (i = 0; i < MAX_CHANNEL; i++) {
- new_card->current_applet[i] = NULL;
- }
- new_card->vcard_buffer_response = NULL;
+ new_card = g_new0(VCard, 1);
new_card->type = VCARD_VM;
new_card->vcard_private = private;
new_card->vcard_private_free = private_free;
- new_card->vcard_get_atr = NULL;
new_card->reference_count = 1;
return new_card;
}
diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c
index e2b196d..75b9d79 100644
--- a/libcacard/vcard_emul_nss.c
+++ b/libcacard/vcard_emul_nss.c
@@ -94,9 +94,9 @@ static void
vcard_emul_alloc_arrays(unsigned char ***certsp, int **cert_lenp,
VCardKey ***keysp, int cert_count)
{
- *certsp = (unsigned char **)g_malloc(sizeof(unsigned char *)*cert_count);
- *cert_lenp = (int *)g_malloc(sizeof(int)*cert_count);
- *keysp = (VCardKey **)g_malloc(sizeof(VCardKey *)*cert_count);
+ *certsp = g_new(unsigned char *, cert_count);
+ *cert_lenp = g_new(int, cert_count);
+ *keysp = g_new(VCardKey *, cert_count);
}
/*
@@ -139,7 +139,7 @@ vcard_emul_make_key(PK11SlotInfo *slot, CERTCertificate *cert)
{
VCardKey *key;
- key = (VCardKey *)g_malloc(sizeof(VCardKey));
+ key = g_new(VCardKey, 1);
key->slot = PK11_ReferenceSlot(slot);
key->cert = CERT_DupCertificate(cert);
/* NOTE: if we aren't logged into the token, this could return NULL */
@@ -449,7 +449,7 @@ vreader_emul_new(PK11SlotInfo *slot, VCardEmulType type, const char *params)
{
VReaderEmul *new_reader_emul;
- new_reader_emul = (VReaderEmul *)g_malloc(sizeof(VReaderEmul));
+ new_reader_emul = g_new(VReaderEmul, 1);
new_reader_emul->slot = PK11_ReferenceSlot(slot);
new_reader_emul->default_type = type;
@@ -1189,7 +1189,7 @@ vcard_emul_options(const char *args)
g_strndup(type_params, type_params_length);
count = count_tokens(args, ',', ')') + 1;
vreaderOpt->cert_count = count;
- vreaderOpt->cert_name = (char **)g_malloc(count*sizeof(char *));
+ vreaderOpt->cert_name = g_new(char *, count);
for (i = 0; i < count; i++) {
const char *cert = args;
args = strpbrk(args, ",)");
diff --git a/libcacard/vreader.c b/libcacard/vreader.c
index 7720295..9304a28 100644
--- a/libcacard/vreader.c
+++ b/libcacard/vreader.c
@@ -115,7 +115,7 @@ vreader_new(const char *name, VReaderEmul *private,
{
VReader *reader;
- reader = (VReader *)g_malloc(sizeof(VReader));
+ reader = g_new(VReader, 1);
qemu_mutex_init(&reader->lock);
reader->reference_count = 1;
reader->name = g_strdup(name);
@@ -312,10 +312,7 @@ vreader_list_entry_new(VReader *reader)
{
VReaderListEntry *new_reader_list_entry;
- new_reader_list_entry = (VReaderListEntry *)
- g_malloc(sizeof(VReaderListEntry));
- new_reader_list_entry->next = NULL;
- new_reader_list_entry->prev = NULL;
+ new_reader_list_entry = g_new0(VReaderListEntry, 1);
new_reader_list_entry->reader = vreader_reference(reader);
return new_reader_list_entry;
}
@@ -336,9 +333,7 @@ vreader_list_new(void)
{
VReaderList *new_reader_list;
- new_reader_list = (VReaderList *)g_malloc(sizeof(VReaderList));
- new_reader_list->head = NULL;
- new_reader_list->tail = NULL;
+ new_reader_list = g_new0(VReaderList, 1);
return new_reader_list;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-trivial] [PULL 02/23] iohandler.c: Properly initialize sigaction struct
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
@ 2014-05-26 7:19 ` Michael Tokarev
-1 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:19 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Peter Maydell, Michael Tokarev
From: Peter Maydell <peter.maydell@linaro.org>
The code in qemu_init_child_watch() wasn't clearing the 'struct
sigaction' before passing it to sigaction(); this meant that we
would block a random set of signals while executing the SIGCHLD
handler. Initialize properly by using memset() on the struct,
as we do in similar cases elsewhere.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
iohandler.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/iohandler.c b/iohandler.c
index ae2ef8f..cca614f 100644
--- a/iohandler.c
+++ b/iohandler.c
@@ -191,6 +191,7 @@ static void qemu_init_child_watch(void)
struct sigaction act;
sigchld_bh = qemu_bh_new(sigchld_bh_handler, NULL);
+ memset(&act, 0, sizeof(act));
act.sa_handler = sigchld_handler;
act.sa_flags = SA_NOCLDSTOP;
sigaction(SIGCHLD, &act, NULL);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-devel] [PULL 02/23] iohandler.c: Properly initialize sigaction struct
@ 2014-05-26 7:19 ` Michael Tokarev
0 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:19 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Peter Maydell, Michael Tokarev
From: Peter Maydell <peter.maydell@linaro.org>
The code in qemu_init_child_watch() wasn't clearing the 'struct
sigaction' before passing it to sigaction(); this meant that we
would block a random set of signals while executing the SIGCHLD
handler. Initialize properly by using memset() on the struct,
as we do in similar cases elsewhere.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
iohandler.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/iohandler.c b/iohandler.c
index ae2ef8f..cca614f 100644
--- a/iohandler.c
+++ b/iohandler.c
@@ -191,6 +191,7 @@ static void qemu_init_child_watch(void)
struct sigaction act;
sigchld_bh = qemu_bh_new(sigchld_bh_handler, NULL);
+ memset(&act, 0, sizeof(act));
act.sa_handler = sigchld_handler;
act.sa_flags = SA_NOCLDSTOP;
sigaction(SIGCHLD, &act, NULL);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-trivial] [PULL 03/23] nbd: Close socket on negotiation failure.
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
@ 2014-05-26 7:19 ` Michael Tokarev
-1 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:19 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-trivial, Hani Benhabiles, Michael Tokarev, Hani Benhabiles
From: Hani Benhabiles <kroosec@gmail.com>
Otherwise, the nbd client may hang waiting for the server response.
Signed-off-by: Hani Benhabiles <hani@linux.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
blockdev-nbd.c | 4 ++--
qemu-nbd.c | 4 +++-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index 922cf56..b60b66d 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -27,8 +27,8 @@ static void nbd_accept(void *opaque)
socklen_t addr_len = sizeof(addr);
int fd = accept(server_fd, (struct sockaddr *)&addr, &addr_len);
- if (fd >= 0) {
- nbd_client_new(NULL, fd, nbd_client_put);
+ if (fd >= 0 && !nbd_client_new(NULL, fd, nbd_client_put)) {
+ close(fd);
}
}
diff --git a/qemu-nbd.c b/qemu-nbd.c
index eed79fa..f70e4b0 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -369,8 +369,10 @@ static void nbd_accept(void *opaque)
return;
}
- if (fd >= 0 && nbd_client_new(exp, fd, nbd_client_closed)) {
+ if (nbd_client_new(exp, fd, nbd_client_closed)) {
nb_fds++;
+ } else {
+ close(fd);
}
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-devel] [PULL 03/23] nbd: Close socket on negotiation failure.
@ 2014-05-26 7:19 ` Michael Tokarev
0 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:19 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-trivial, Hani Benhabiles, Michael Tokarev, Hani Benhabiles
From: Hani Benhabiles <kroosec@gmail.com>
Otherwise, the nbd client may hang waiting for the server response.
Signed-off-by: Hani Benhabiles <hani@linux.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
blockdev-nbd.c | 4 ++--
qemu-nbd.c | 4 +++-
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/blockdev-nbd.c b/blockdev-nbd.c
index 922cf56..b60b66d 100644
--- a/blockdev-nbd.c
+++ b/blockdev-nbd.c
@@ -27,8 +27,8 @@ static void nbd_accept(void *opaque)
socklen_t addr_len = sizeof(addr);
int fd = accept(server_fd, (struct sockaddr *)&addr, &addr_len);
- if (fd >= 0) {
- nbd_client_new(NULL, fd, nbd_client_put);
+ if (fd >= 0 && !nbd_client_new(NULL, fd, nbd_client_put)) {
+ close(fd);
}
}
diff --git a/qemu-nbd.c b/qemu-nbd.c
index eed79fa..f70e4b0 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -369,8 +369,10 @@ static void nbd_accept(void *opaque)
return;
}
- if (fd >= 0 && nbd_client_new(exp, fd, nbd_client_closed)) {
+ if (nbd_client_new(exp, fd, nbd_client_closed)) {
nb_fds++;
+ } else {
+ close(fd);
}
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-trivial] [PULL 04/23] nbd: Miscellaneous typo fixes.
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
@ 2014-05-26 7:19 ` Michael Tokarev
-1 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:19 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-trivial, Hani Benhabiles, Michael Tokarev, Hani Benhabiles
From: Hani Benhabiles <kroosec@gmail.com>
Signed-off-by: Hani Benhabiles <hani@linux.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
nbd.c | 2 +-
qemu-nbd.c | 2 +-
qemu-nbd.texi | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/nbd.c b/nbd.c
index e5084b6..e0d032c 100644
--- a/nbd.c
+++ b/nbd.c
@@ -306,7 +306,7 @@ static int nbd_send_negotiate(NBDClient *client)
[ 8 .. 15] magic (NBD_CLIENT_MAGIC)
[16 .. 23] size
[24 .. 25] server flags (0)
- [24 .. 27] export flags
+ [26 .. 27] export flags
[28 .. 151] reserved (0)
Negotiation header with options, part 1:
diff --git a/qemu-nbd.c b/qemu-nbd.c
index f70e4b0..cd6bd50 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -294,7 +294,7 @@ static void *nbd_client_thread(void *arg)
fd = open(device, O_RDWR);
if (fd < 0) {
/* Linux-only, we can use %m in printf. */
- fprintf(stderr, "Failed to open %s: %m", device);
+ fprintf(stderr, "Failed to open %s: %m\n", device);
goto out_socket;
}
diff --git a/qemu-nbd.texi b/qemu-nbd.texi
index 0a7e013..46fd483 100644
--- a/qemu-nbd.texi
+++ b/qemu-nbd.texi
@@ -15,7 +15,7 @@ Export QEMU disk image using NBD protocol.
@item @var{filename}
is a disk image filename
@item -p, --port=@var{port}
- port to listen on (default @samp{1024})
+ port to listen on (default @samp{10809})
@item -o, --offset=@var{offset}
offset into the image
@item -b, --bind=@var{iface}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-devel] [PULL 04/23] nbd: Miscellaneous typo fixes.
@ 2014-05-26 7:19 ` Michael Tokarev
0 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:19 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-trivial, Hani Benhabiles, Michael Tokarev, Hani Benhabiles
From: Hani Benhabiles <kroosec@gmail.com>
Signed-off-by: Hani Benhabiles <hani@linux.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
nbd.c | 2 +-
qemu-nbd.c | 2 +-
qemu-nbd.texi | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/nbd.c b/nbd.c
index e5084b6..e0d032c 100644
--- a/nbd.c
+++ b/nbd.c
@@ -306,7 +306,7 @@ static int nbd_send_negotiate(NBDClient *client)
[ 8 .. 15] magic (NBD_CLIENT_MAGIC)
[16 .. 23] size
[24 .. 25] server flags (0)
- [24 .. 27] export flags
+ [26 .. 27] export flags
[28 .. 151] reserved (0)
Negotiation header with options, part 1:
diff --git a/qemu-nbd.c b/qemu-nbd.c
index f70e4b0..cd6bd50 100644
--- a/qemu-nbd.c
+++ b/qemu-nbd.c
@@ -294,7 +294,7 @@ static void *nbd_client_thread(void *arg)
fd = open(device, O_RDWR);
if (fd < 0) {
/* Linux-only, we can use %m in printf. */
- fprintf(stderr, "Failed to open %s: %m", device);
+ fprintf(stderr, "Failed to open %s: %m\n", device);
goto out_socket;
}
diff --git a/qemu-nbd.texi b/qemu-nbd.texi
index 0a7e013..46fd483 100644
--- a/qemu-nbd.texi
+++ b/qemu-nbd.texi
@@ -15,7 +15,7 @@ Export QEMU disk image using NBD protocol.
@item @var{filename}
is a disk image filename
@item -p, --port=@var{port}
- port to listen on (default @samp{1024})
+ port to listen on (default @samp{10809})
@item -o, --offset=@var{offset}
offset into the image
@item -b, --bind=@var{iface}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-trivial] [PULL 05/23] configure: Automatically select GTK+ 3.0 if GTK+ 2.0 is unavailable
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
@ 2014-05-26 7:19 ` Michael Tokarev
-1 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:19 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Stefan Weil, Michael Tokarev
From: Stefan Weil <sw@weilnetz.de>
The configure option --with-gtkabi=3.0 is still supported, but no longer
needed when GTK+-2.0 is missing. When no GTK+ ABI is selected by the
user, configure first tries 2.0, then 3.0.
For some platforms (e.g. Windows) newer binaries of GTK+ are only
available for GTK+ 3.0. Now building on these platforms is a little bit
easier.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
configure | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/configure b/configure
index 605a0ec..678a106 100755
--- a/configure
+++ b/configure
@@ -317,7 +317,7 @@ glusterfs_discard="no"
glusterfs_zerofill="no"
virtio_blk_data_plane=""
gtk=""
-gtkabi="2.0"
+gtkabi=""
vte=""
tpm="no"
libssh2=""
@@ -1970,6 +1970,18 @@ fi
##########################################
# GTK probe
+if test "$gtkabi" = ""; then
+ # The GTK ABI was not specified explicitly, so try whether 2.0 is available.
+ # Use 3.0 as a fallback if that is available.
+ if $pkg_config --exists "gtk+-2.0 >= 2.18.0"; then
+ gtkabi=2.0
+ elif $pkg_config --exists "gtk+-3.0 >= 3.0.0"; then
+ gtkabi=3.0
+ else
+ gtkabi=2.0
+ fi
+fi
+
if test "$gtk" != "no"; then
gtkpackage="gtk+-$gtkabi"
if test "$gtkabi" = "3.0" ; then
@@ -1983,7 +1995,7 @@ if test "$gtk" != "no"; then
libs_softmmu="$gtk_libs $libs_softmmu"
gtk="yes"
elif test "$gtk" = "yes"; then
- feature_not_found "gtk" "Install gtk2 or gtk3 (requires --with-gtkabi=3.0 option to configure) devel"
+ feature_not_found "gtk" "Install gtk2 or gtk3 devel"
else
gtk="no"
fi
@@ -2006,7 +2018,11 @@ if test "$vte" != "no"; then
libs_softmmu="$vte_libs $libs_softmmu"
vte="yes"
elif test "$vte" = "yes"; then
- feature_not_found "vte" "Install libvte or libvte-2.90 (requires --with-gtkabi=3.0 option to configure) devel"
+ if test "$gtkabi" = "3.0"; then
+ feature_not_found "vte" "Install libvte-2.90 devel"
+ else
+ feature_not_found "vte" "Install libvte devel"
+ fi
else
vte="no"
fi
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-devel] [PULL 05/23] configure: Automatically select GTK+ 3.0 if GTK+ 2.0 is unavailable
@ 2014-05-26 7:19 ` Michael Tokarev
0 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:19 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Stefan Weil, Michael Tokarev
From: Stefan Weil <sw@weilnetz.de>
The configure option --with-gtkabi=3.0 is still supported, but no longer
needed when GTK+-2.0 is missing. When no GTK+ ABI is selected by the
user, configure first tries 2.0, then 3.0.
For some platforms (e.g. Windows) newer binaries of GTK+ are only
available for GTK+ 3.0. Now building on these platforms is a little bit
easier.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
configure | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/configure b/configure
index 605a0ec..678a106 100755
--- a/configure
+++ b/configure
@@ -317,7 +317,7 @@ glusterfs_discard="no"
glusterfs_zerofill="no"
virtio_blk_data_plane=""
gtk=""
-gtkabi="2.0"
+gtkabi=""
vte=""
tpm="no"
libssh2=""
@@ -1970,6 +1970,18 @@ fi
##########################################
# GTK probe
+if test "$gtkabi" = ""; then
+ # The GTK ABI was not specified explicitly, so try whether 2.0 is available.
+ # Use 3.0 as a fallback if that is available.
+ if $pkg_config --exists "gtk+-2.0 >= 2.18.0"; then
+ gtkabi=2.0
+ elif $pkg_config --exists "gtk+-3.0 >= 3.0.0"; then
+ gtkabi=3.0
+ else
+ gtkabi=2.0
+ fi
+fi
+
if test "$gtk" != "no"; then
gtkpackage="gtk+-$gtkabi"
if test "$gtkabi" = "3.0" ; then
@@ -1983,7 +1995,7 @@ if test "$gtk" != "no"; then
libs_softmmu="$gtk_libs $libs_softmmu"
gtk="yes"
elif test "$gtk" = "yes"; then
- feature_not_found "gtk" "Install gtk2 or gtk3 (requires --with-gtkabi=3.0 option to configure) devel"
+ feature_not_found "gtk" "Install gtk2 or gtk3 devel"
else
gtk="no"
fi
@@ -2006,7 +2018,11 @@ if test "$vte" != "no"; then
libs_softmmu="$vte_libs $libs_softmmu"
vte="yes"
elif test "$vte" = "yes"; then
- feature_not_found "vte" "Install libvte or libvte-2.90 (requires --with-gtkabi=3.0 option to configure) devel"
+ if test "$gtkabi" = "3.0"; then
+ feature_not_found "vte" "Install libvte-2.90 devel"
+ else
+ feature_not_found "vte" "Install libvte devel"
+ fi
else
vte="no"
fi
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-trivial] [PULL 06/23] bswap.h: Rename ldl_p, stl_p, etc to ldl_he_p, stl_he_p, etc
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
@ 2014-05-26 7:19 ` Michael Tokarev
-1 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:19 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Peter Maydell, Michael Tokarev
From: Peter Maydell <peter.maydell@linaro.org>
We have an unfortunate naming clash between the functions
ldl_p, stl_p, etc defined in bswap.h (which have semantics
"load/store in host endianness") and the #defines of the same
name in cpu-all.h (which have the semantics "load/store in
target endianness").
Fortunately it turns out that the only users of the bswap.h
functions are all within bswap.h itself, so we can simply
rename them to include a _he_ infix for "host endianness".
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
include/qemu/bswap.h | 45 +++++++++++++++++++++++----------------------
1 file changed, 23 insertions(+), 22 deletions(-)
diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h
index 0f9c6cf..78c1ced 100644
--- a/include/qemu/bswap.h
+++ b/include/qemu/bswap.h
@@ -215,9 +215,10 @@ typedef union {
* q: 64 bits
*
* endian is:
- * (empty): host endian
+ * he : host endian
* be : big endian
* le : little endian
+ * (except for byte accesses, which have no endian infix).
*/
static inline int ldub_p(const void *ptr)
@@ -239,82 +240,82 @@ static inline void stb_p(void *ptr, uint8_t v)
operations. Thus we don't need to play games with packed attributes, or
inline byte-by-byte stores. */
-static inline int lduw_p(const void *ptr)
+static inline int lduw_he_p(const void *ptr)
{
uint16_t r;
memcpy(&r, ptr, sizeof(r));
return r;
}
-static inline int ldsw_p(const void *ptr)
+static inline int ldsw_he_p(const void *ptr)
{
int16_t r;
memcpy(&r, ptr, sizeof(r));
return r;
}
-static inline void stw_p(void *ptr, uint16_t v)
+static inline void stw_he_p(void *ptr, uint16_t v)
{
memcpy(ptr, &v, sizeof(v));
}
-static inline int ldl_p(const void *ptr)
+static inline int ldl_he_p(const void *ptr)
{
int32_t r;
memcpy(&r, ptr, sizeof(r));
return r;
}
-static inline void stl_p(void *ptr, uint32_t v)
+static inline void stl_he_p(void *ptr, uint32_t v)
{
memcpy(ptr, &v, sizeof(v));
}
-static inline uint64_t ldq_p(const void *ptr)
+static inline uint64_t ldq_he_p(const void *ptr)
{
uint64_t r;
memcpy(&r, ptr, sizeof(r));
return r;
}
-static inline void stq_p(void *ptr, uint64_t v)
+static inline void stq_he_p(void *ptr, uint64_t v)
{
memcpy(ptr, &v, sizeof(v));
}
static inline int lduw_le_p(const void *ptr)
{
- return (uint16_t)le_bswap(lduw_p(ptr), 16);
+ return (uint16_t)le_bswap(lduw_he_p(ptr), 16);
}
static inline int ldsw_le_p(const void *ptr)
{
- return (int16_t)le_bswap(lduw_p(ptr), 16);
+ return (int16_t)le_bswap(lduw_he_p(ptr), 16);
}
static inline int ldl_le_p(const void *ptr)
{
- return le_bswap(ldl_p(ptr), 32);
+ return le_bswap(ldl_he_p(ptr), 32);
}
static inline uint64_t ldq_le_p(const void *ptr)
{
- return le_bswap(ldq_p(ptr), 64);
+ return le_bswap(ldq_he_p(ptr), 64);
}
static inline void stw_le_p(void *ptr, uint16_t v)
{
- stw_p(ptr, le_bswap(v, 16));
+ stw_he_p(ptr, le_bswap(v, 16));
}
static inline void stl_le_p(void *ptr, uint32_t v)
{
- stl_p(ptr, le_bswap(v, 32));
+ stl_he_p(ptr, le_bswap(v, 32));
}
static inline void stq_le_p(void *ptr, uint64_t v)
{
- stq_p(ptr, le_bswap(v, 64));
+ stq_he_p(ptr, le_bswap(v, 64));
}
/* float access */
@@ -349,37 +350,37 @@ static inline void stfq_le_p(void *ptr, float64 v)
static inline int lduw_be_p(const void *ptr)
{
- return (uint16_t)be_bswap(lduw_p(ptr), 16);
+ return (uint16_t)be_bswap(lduw_he_p(ptr), 16);
}
static inline int ldsw_be_p(const void *ptr)
{
- return (int16_t)be_bswap(lduw_p(ptr), 16);
+ return (int16_t)be_bswap(lduw_he_p(ptr), 16);
}
static inline int ldl_be_p(const void *ptr)
{
- return be_bswap(ldl_p(ptr), 32);
+ return be_bswap(ldl_he_p(ptr), 32);
}
static inline uint64_t ldq_be_p(const void *ptr)
{
- return be_bswap(ldq_p(ptr), 64);
+ return be_bswap(ldq_he_p(ptr), 64);
}
static inline void stw_be_p(void *ptr, uint16_t v)
{
- stw_p(ptr, be_bswap(v, 16));
+ stw_he_p(ptr, be_bswap(v, 16));
}
static inline void stl_be_p(void *ptr, uint32_t v)
{
- stl_p(ptr, be_bswap(v, 32));
+ stl_he_p(ptr, be_bswap(v, 32));
}
static inline void stq_be_p(void *ptr, uint64_t v)
{
- stq_p(ptr, be_bswap(v, 64));
+ stq_he_p(ptr, be_bswap(v, 64));
}
/* float access */
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-devel] [PULL 06/23] bswap.h: Rename ldl_p, stl_p, etc to ldl_he_p, stl_he_p, etc
@ 2014-05-26 7:19 ` Michael Tokarev
0 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:19 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Peter Maydell, Michael Tokarev
From: Peter Maydell <peter.maydell@linaro.org>
We have an unfortunate naming clash between the functions
ldl_p, stl_p, etc defined in bswap.h (which have semantics
"load/store in host endianness") and the #defines of the same
name in cpu-all.h (which have the semantics "load/store in
target endianness").
Fortunately it turns out that the only users of the bswap.h
functions are all within bswap.h itself, so we can simply
rename them to include a _he_ infix for "host endianness".
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
include/qemu/bswap.h | 45 +++++++++++++++++++++++----------------------
1 file changed, 23 insertions(+), 22 deletions(-)
diff --git a/include/qemu/bswap.h b/include/qemu/bswap.h
index 0f9c6cf..78c1ced 100644
--- a/include/qemu/bswap.h
+++ b/include/qemu/bswap.h
@@ -215,9 +215,10 @@ typedef union {
* q: 64 bits
*
* endian is:
- * (empty): host endian
+ * he : host endian
* be : big endian
* le : little endian
+ * (except for byte accesses, which have no endian infix).
*/
static inline int ldub_p(const void *ptr)
@@ -239,82 +240,82 @@ static inline void stb_p(void *ptr, uint8_t v)
operations. Thus we don't need to play games with packed attributes, or
inline byte-by-byte stores. */
-static inline int lduw_p(const void *ptr)
+static inline int lduw_he_p(const void *ptr)
{
uint16_t r;
memcpy(&r, ptr, sizeof(r));
return r;
}
-static inline int ldsw_p(const void *ptr)
+static inline int ldsw_he_p(const void *ptr)
{
int16_t r;
memcpy(&r, ptr, sizeof(r));
return r;
}
-static inline void stw_p(void *ptr, uint16_t v)
+static inline void stw_he_p(void *ptr, uint16_t v)
{
memcpy(ptr, &v, sizeof(v));
}
-static inline int ldl_p(const void *ptr)
+static inline int ldl_he_p(const void *ptr)
{
int32_t r;
memcpy(&r, ptr, sizeof(r));
return r;
}
-static inline void stl_p(void *ptr, uint32_t v)
+static inline void stl_he_p(void *ptr, uint32_t v)
{
memcpy(ptr, &v, sizeof(v));
}
-static inline uint64_t ldq_p(const void *ptr)
+static inline uint64_t ldq_he_p(const void *ptr)
{
uint64_t r;
memcpy(&r, ptr, sizeof(r));
return r;
}
-static inline void stq_p(void *ptr, uint64_t v)
+static inline void stq_he_p(void *ptr, uint64_t v)
{
memcpy(ptr, &v, sizeof(v));
}
static inline int lduw_le_p(const void *ptr)
{
- return (uint16_t)le_bswap(lduw_p(ptr), 16);
+ return (uint16_t)le_bswap(lduw_he_p(ptr), 16);
}
static inline int ldsw_le_p(const void *ptr)
{
- return (int16_t)le_bswap(lduw_p(ptr), 16);
+ return (int16_t)le_bswap(lduw_he_p(ptr), 16);
}
static inline int ldl_le_p(const void *ptr)
{
- return le_bswap(ldl_p(ptr), 32);
+ return le_bswap(ldl_he_p(ptr), 32);
}
static inline uint64_t ldq_le_p(const void *ptr)
{
- return le_bswap(ldq_p(ptr), 64);
+ return le_bswap(ldq_he_p(ptr), 64);
}
static inline void stw_le_p(void *ptr, uint16_t v)
{
- stw_p(ptr, le_bswap(v, 16));
+ stw_he_p(ptr, le_bswap(v, 16));
}
static inline void stl_le_p(void *ptr, uint32_t v)
{
- stl_p(ptr, le_bswap(v, 32));
+ stl_he_p(ptr, le_bswap(v, 32));
}
static inline void stq_le_p(void *ptr, uint64_t v)
{
- stq_p(ptr, le_bswap(v, 64));
+ stq_he_p(ptr, le_bswap(v, 64));
}
/* float access */
@@ -349,37 +350,37 @@ static inline void stfq_le_p(void *ptr, float64 v)
static inline int lduw_be_p(const void *ptr)
{
- return (uint16_t)be_bswap(lduw_p(ptr), 16);
+ return (uint16_t)be_bswap(lduw_he_p(ptr), 16);
}
static inline int ldsw_be_p(const void *ptr)
{
- return (int16_t)be_bswap(lduw_p(ptr), 16);
+ return (int16_t)be_bswap(lduw_he_p(ptr), 16);
}
static inline int ldl_be_p(const void *ptr)
{
- return be_bswap(ldl_p(ptr), 32);
+ return be_bswap(ldl_he_p(ptr), 32);
}
static inline uint64_t ldq_be_p(const void *ptr)
{
- return be_bswap(ldq_p(ptr), 64);
+ return be_bswap(ldq_he_p(ptr), 64);
}
static inline void stw_be_p(void *ptr, uint16_t v)
{
- stw_p(ptr, be_bswap(v, 16));
+ stw_he_p(ptr, be_bswap(v, 16));
}
static inline void stl_be_p(void *ptr, uint32_t v)
{
- stl_p(ptr, be_bswap(v, 32));
+ stl_he_p(ptr, be_bswap(v, 32));
}
static inline void stq_be_p(void *ptr, uint64_t v)
{
- stq_p(ptr, be_bswap(v, 64));
+ stq_he_p(ptr, be_bswap(v, 64));
}
/* float access */
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-trivial] [PULL 07/23] jazz_led: Add missing break in switch case
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
@ 2014-05-26 7:19 ` Michael Tokarev
-1 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:19 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Saravanakumar, Michael Tokarev
From: Saravanakumar <saravanakumar.punith@gmail.com>
Signed-off-by: Saravanakumar <saravanakumar.punith@gmail.com>
Reviewed-by: Paolo Bonizni <pbonzini@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
hw/display/jazz_led.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/display/jazz_led.c b/hw/display/jazz_led.c
index e9bb005..12b1707 100644
--- a/hw/display/jazz_led.c
+++ b/hw/display/jazz_led.c
@@ -173,6 +173,7 @@ static void jazz_led_update_display(void *opaque)
case 16:
color_segment = rgb_to_pixel16(0xaa, 0xaa, 0xaa);
color_led = rgb_to_pixel16(0x00, 0xff, 0x00);
+ break;
case 24:
color_segment = rgb_to_pixel24(0xaa, 0xaa, 0xaa);
color_led = rgb_to_pixel24(0x00, 0xff, 0x00);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-devel] [PULL 07/23] jazz_led: Add missing break in switch case
@ 2014-05-26 7:19 ` Michael Tokarev
0 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:19 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Saravanakumar, Michael Tokarev
From: Saravanakumar <saravanakumar.punith@gmail.com>
Signed-off-by: Saravanakumar <saravanakumar.punith@gmail.com>
Reviewed-by: Paolo Bonizni <pbonzini@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
hw/display/jazz_led.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/hw/display/jazz_led.c b/hw/display/jazz_led.c
index e9bb005..12b1707 100644
--- a/hw/display/jazz_led.c
+++ b/hw/display/jazz_led.c
@@ -173,6 +173,7 @@ static void jazz_led_update_display(void *opaque)
case 16:
color_segment = rgb_to_pixel16(0xaa, 0xaa, 0xaa);
color_led = rgb_to_pixel16(0x00, 0xff, 0x00);
+ break;
case 24:
color_segment = rgb_to_pixel24(0xaa, 0xaa, 0xaa);
color_led = rgb_to_pixel24(0x00, 0xff, 0x00);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-trivial] [PULL 08/23] pci: move dereferencing of root only after verifying valid root pointer
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
@ 2014-05-26 7:19 ` Michael Tokarev
-1 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:19 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Saravanakumar, Michael Tokarev
From: Saravanakumar <saravanakumar.punith@gmail.com>
Signed-off-by: Saravanakumar <saravanakumar.punith@gmail.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
hw/pci/pci.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 22fe5ee..8d6a8d4 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -605,13 +605,13 @@ PCIBus *pci_get_bus_devfn(int *devfnp, PCIBus *root, const char *devaddr)
int dom, bus;
unsigned slot;
- assert(!root->parent_dev);
-
if (!root) {
fprintf(stderr, "No primary PCI bus\n");
return NULL;
}
+ assert(!root->parent_dev);
+
if (!devaddr) {
*devfnp = -1;
return pci_find_bus_nr(root, 0);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-devel] [PULL 08/23] pci: move dereferencing of root only after verifying valid root pointer
@ 2014-05-26 7:19 ` Michael Tokarev
0 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:19 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Saravanakumar, Michael Tokarev
From: Saravanakumar <saravanakumar.punith@gmail.com>
Signed-off-by: Saravanakumar <saravanakumar.punith@gmail.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
hw/pci/pci.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/pci/pci.c b/hw/pci/pci.c
index 22fe5ee..8d6a8d4 100644
--- a/hw/pci/pci.c
+++ b/hw/pci/pci.c
@@ -605,13 +605,13 @@ PCIBus *pci_get_bus_devfn(int *devfnp, PCIBus *root, const char *devaddr)
int dom, bus;
unsigned slot;
- assert(!root->parent_dev);
-
if (!root) {
fprintf(stderr, "No primary PCI bus\n");
return NULL;
}
+ assert(!root->parent_dev);
+
if (!devaddr) {
*devfnp = -1;
return pci_find_bus_nr(root, 0);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-trivial] [PULL 09/23] arch_init: replace fprintf(stderr, ...) with error_report()
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
@ 2014-05-26 7:19 ` Michael Tokarev
-1 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:19 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev, Le Tan
From: Le Tan <tamlokveer@gmail.com>
Replace fprintf(stderr,...) with error_report() in the file
arch_init.c. The trailing "\n"s of the @fmt argument have been removed
because @fmt of error_report() should not contain newline.
Signed-off-by: Le Tan <tamlokveer@gmail.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
arch_init.c | 32 +++++++++++++++-----------------
1 file changed, 15 insertions(+), 17 deletions(-)
diff --git a/arch_init.c b/arch_init.c
index 685ba0e..9f1a174 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -975,12 +975,12 @@ static int load_xbzrle(QEMUFile *f, ram_addr_t addr, void *host)
xh_len = qemu_get_be16(f);
if (xh_flags != ENCODING_FLAG_XBZRLE) {
- fprintf(stderr, "Failed to load XBZRLE page - wrong compression!\n");
+ error_report("Failed to load XBZRLE page - wrong compression!");
return -1;
}
if (xh_len > TARGET_PAGE_SIZE) {
- fprintf(stderr, "Failed to load XBZRLE page - len overflow!\n");
+ error_report("Failed to load XBZRLE page - len overflow!");
return -1;
}
/* load data and decode */
@@ -989,7 +989,7 @@ static int load_xbzrle(QEMUFile *f, ram_addr_t addr, void *host)
/* decode RLE */
if (xbzrle_decode_buffer(xbzrle_decoded_buf, xh_len, host,
TARGET_PAGE_SIZE) == -1) {
- fprintf(stderr, "Failed to load XBZRLE page - decode error!\n");
+ error_report("Failed to load XBZRLE page - decode error!");
return -1;
}
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
if (flags & RAM_SAVE_FLAG_CONTINUE) {
if (!block) {
- fprintf(stderr, "Ack, bad migration stream!\n");
+ error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1022,7 +1022,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
return memory_region_get_ram_ptr(block->mr) + offset;
}
- fprintf(stderr, "Can't find block %s!\n", id);
+ error_report("Can't find block %s!", id);
return NULL;
}
@@ -1075,10 +1075,9 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
if (!strncmp(id, block->idstr, sizeof(id))) {
if (block->length != length) {
- fprintf(stderr,
- "Length mismatch: %s: " RAM_ADDR_FMT
- " in != " RAM_ADDR_FMT "\n", id, length,
- block->length);
+ error_report("Length mismatch: %s: " RAM_ADDR_FMT
+ " in != " RAM_ADDR_FMT, id, length,
+ block->length);
ret = -EINVAL;
goto done;
}
@@ -1087,8 +1086,8 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
}
if (!block) {
- fprintf(stderr, "Unknown ramblock \"%s\", cannot "
- "accept migration\n", id);
+ error_report("Unknown ramblock \"%s\", cannot "
+ "accept migration", id);
ret = -EINVAL;
goto done;
}
@@ -1243,12 +1242,11 @@ void select_soundhw(const char *optarg)
if (!c->name) {
if (l > 80) {
- fprintf(stderr,
- "Unknown sound card name (too big to show)\n");
+ error_report("Unknown sound card name (too big to show)");
}
else {
- fprintf(stderr, "Unknown sound card name `%.*s'\n",
- (int) l, p);
+ error_report("Unknown sound card name `%.*s'",
+ (int) l, p);
}
bad_card = 1;
}
@@ -1271,13 +1269,13 @@ void audio_init(void)
if (c->enabled) {
if (c->isa) {
if (!isa_bus) {
- fprintf(stderr, "ISA bus not available for %s\n", c->name);
+ error_report("ISA bus not available for %s", c->name);
exit(1);
}
c->init.init_isa(isa_bus);
} else {
if (!pci_bus) {
- fprintf(stderr, "PCI bus not available for %s\n", c->name);
+ error_report("PCI bus not available for %s", c->name);
exit(1);
}
c->init.init_pci(pci_bus);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-devel] [PULL 09/23] arch_init: replace fprintf(stderr, ...) with error_report()
@ 2014-05-26 7:19 ` Michael Tokarev
0 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:19 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev, Le Tan
From: Le Tan <tamlokveer@gmail.com>
Replace fprintf(stderr,...) with error_report() in the file
arch_init.c. The trailing "\n"s of the @fmt argument have been removed
because @fmt of error_report() should not contain newline.
Signed-off-by: Le Tan <tamlokveer@gmail.com>
Reviewed-by: Andreas Färber <afaerber@suse.de>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
arch_init.c | 32 +++++++++++++++-----------------
1 file changed, 15 insertions(+), 17 deletions(-)
diff --git a/arch_init.c b/arch_init.c
index 685ba0e..9f1a174 100644
--- a/arch_init.c
+++ b/arch_init.c
@@ -975,12 +975,12 @@ static int load_xbzrle(QEMUFile *f, ram_addr_t addr, void *host)
xh_len = qemu_get_be16(f);
if (xh_flags != ENCODING_FLAG_XBZRLE) {
- fprintf(stderr, "Failed to load XBZRLE page - wrong compression!\n");
+ error_report("Failed to load XBZRLE page - wrong compression!");
return -1;
}
if (xh_len > TARGET_PAGE_SIZE) {
- fprintf(stderr, "Failed to load XBZRLE page - len overflow!\n");
+ error_report("Failed to load XBZRLE page - len overflow!");
return -1;
}
/* load data and decode */
@@ -989,7 +989,7 @@ static int load_xbzrle(QEMUFile *f, ram_addr_t addr, void *host)
/* decode RLE */
if (xbzrle_decode_buffer(xbzrle_decoded_buf, xh_len, host,
TARGET_PAGE_SIZE) == -1) {
- fprintf(stderr, "Failed to load XBZRLE page - decode error!\n");
+ error_report("Failed to load XBZRLE page - decode error!");
return -1;
}
@@ -1006,7 +1006,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
if (flags & RAM_SAVE_FLAG_CONTINUE) {
if (!block) {
- fprintf(stderr, "Ack, bad migration stream!\n");
+ error_report("Ack, bad migration stream!");
return NULL;
}
@@ -1022,7 +1022,7 @@ static inline void *host_from_stream_offset(QEMUFile *f,
return memory_region_get_ram_ptr(block->mr) + offset;
}
- fprintf(stderr, "Can't find block %s!\n", id);
+ error_report("Can't find block %s!", id);
return NULL;
}
@@ -1075,10 +1075,9 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
QTAILQ_FOREACH(block, &ram_list.blocks, next) {
if (!strncmp(id, block->idstr, sizeof(id))) {
if (block->length != length) {
- fprintf(stderr,
- "Length mismatch: %s: " RAM_ADDR_FMT
- " in != " RAM_ADDR_FMT "\n", id, length,
- block->length);
+ error_report("Length mismatch: %s: " RAM_ADDR_FMT
+ " in != " RAM_ADDR_FMT, id, length,
+ block->length);
ret = -EINVAL;
goto done;
}
@@ -1087,8 +1086,8 @@ static int ram_load(QEMUFile *f, void *opaque, int version_id)
}
if (!block) {
- fprintf(stderr, "Unknown ramblock \"%s\", cannot "
- "accept migration\n", id);
+ error_report("Unknown ramblock \"%s\", cannot "
+ "accept migration", id);
ret = -EINVAL;
goto done;
}
@@ -1243,12 +1242,11 @@ void select_soundhw(const char *optarg)
if (!c->name) {
if (l > 80) {
- fprintf(stderr,
- "Unknown sound card name (too big to show)\n");
+ error_report("Unknown sound card name (too big to show)");
}
else {
- fprintf(stderr, "Unknown sound card name `%.*s'\n",
- (int) l, p);
+ error_report("Unknown sound card name `%.*s'",
+ (int) l, p);
}
bad_card = 1;
}
@@ -1271,13 +1269,13 @@ void audio_init(void)
if (c->enabled) {
if (c->isa) {
if (!isa_bus) {
- fprintf(stderr, "ISA bus not available for %s\n", c->name);
+ error_report("ISA bus not available for %s", c->name);
exit(1);
}
c->init.init_isa(isa_bus);
} else {
if (!pci_bus) {
- fprintf(stderr, "PCI bus not available for %s\n", c->name);
+ error_report("PCI bus not available for %s", c->name);
exit(1);
}
c->init.init_pci(pci_bus);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-trivial] [PULL 10/23] dma-helpers: avoid calling dma_bdrv_unmap() twice
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
@ 2014-05-26 7:19 ` Michael Tokarev
-1 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:19 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev, Jules Wang
From: Jules Wang <junqing.wang@cs2c.com.cn>
Calling dma_bdrv_unmap() twice is not necessary and may cause
potential problems if some code changes.
Signed-off-by: Jules Wang <junqing.wang@cs2c.com.cn>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
dma-helpers.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dma-helpers.c b/dma-helpers.c
index 5f421e9..53cbe92 100644
--- a/dma-helpers.c
+++ b/dma-helpers.c
@@ -143,12 +143,12 @@ static void dma_bdrv_cb(void *opaque, int ret)
dbs->acb = NULL;
dbs->sector_num += dbs->iov.size / 512;
- dma_bdrv_unmap(dbs);
if (dbs->sg_cur_index == dbs->sg->nsg || ret < 0) {
dma_complete(dbs, ret);
return;
}
+ dma_bdrv_unmap(dbs);
while (dbs->sg_cur_index < dbs->sg->nsg) {
cur_addr = dbs->sg->sg[dbs->sg_cur_index].base + dbs->sg_cur_byte;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-devel] [PULL 10/23] dma-helpers: avoid calling dma_bdrv_unmap() twice
@ 2014-05-26 7:19 ` Michael Tokarev
0 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:19 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev, Jules Wang
From: Jules Wang <junqing.wang@cs2c.com.cn>
Calling dma_bdrv_unmap() twice is not necessary and may cause
potential problems if some code changes.
Signed-off-by: Jules Wang <junqing.wang@cs2c.com.cn>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
dma-helpers.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dma-helpers.c b/dma-helpers.c
index 5f421e9..53cbe92 100644
--- a/dma-helpers.c
+++ b/dma-helpers.c
@@ -143,12 +143,12 @@ static void dma_bdrv_cb(void *opaque, int ret)
dbs->acb = NULL;
dbs->sector_num += dbs->iov.size / 512;
- dma_bdrv_unmap(dbs);
if (dbs->sg_cur_index == dbs->sg->nsg || ret < 0) {
dma_complete(dbs, ret);
return;
}
+ dma_bdrv_unmap(dbs);
while (dbs->sg_cur_index < dbs->sg->nsg) {
cur_addr = dbs->sg->sg[dbs->sg_cur_index].base + dbs->sg_cur_byte;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-trivial] [PULL 11/23] configure: Put tempfiles in a subdir of the build directory
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
@ 2014-05-26 7:19 ` Michael Tokarev
-1 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:19 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Peter Maydell, Michael Tokarev
From: Peter Maydell <peter.maydell@linaro.org>
When libtool support was added to configure, the new temporary files
were left out of the list of files cleaned up on exit; this results
in a lot of stale .lo files being left around in /tmp. Worse, libtool
creates a /tmp/.libs directory which we can't easily clean up.
Put all our temporary files in a single temporary directory created
as a subdirectory of the build directory, so we can easily clean it up,
and don't need fragile or complicated code for creation to avoid it
clashing with temporary directories from other instances of QEMU
configure or being subject to attack from adversaries who can write
to /tmp.
Since the temporaries now live in the build tree, we have no
need to jump through hoops with a trap handler to try to remove
them when configure exits; this fixes some weird bugs where hitting
^C during a configure run wouldn't actually make it stop, because
we would run the trap handler but then not stop. (It is possible
to get the trap handler semantics right but it is convoluted largely
because of bugs in dash, so it is simpler to just avoid it.)
Note that "temporary files go in the build directory, not /tmp" is
the way autoconf behaves.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
.gitignore | 1 +
configure | 29 ++++++++++++++++-------------
2 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/.gitignore b/.gitignore
index 8a52709..c658613 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,7 @@
/config-host.*
/config-target.*
/config.status
+/config-temp
/trace/generated-tracers.h
/trace/generated-tracers.c
/trace/generated-tracers-dtrace.h
diff --git a/configure b/configure
index 678a106..cde4325 100755
--- a/configure
+++ b/configure
@@ -2,26 +2,28 @@
#
# qemu configure script (c) 2003 Fabrice Bellard
#
-# set temporary file name
-if test ! -z "$TMPDIR" ; then
- TMPDIR1="${TMPDIR}"
-elif test ! -z "$TEMPDIR" ; then
- TMPDIR1="${TEMPDIR}"
-else
- TMPDIR1="/tmp"
+
+# Temporary directory used for files created while
+# configure runs. Since it is in the build directory
+# we can safely blow away any previous version of it
+# (and we need not jump through hoops to try to delete
+# it when configure exits.)
+TMPDIR1="config-temp"
+rm -rf "${TMPDIR1}"
+mkdir -p "${TMPDIR1}"
+if [ $? -ne 0 ]; then
+ echo "ERROR: failed to create temporary directory"
+ exit 1
fi
-TMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c"
-TMPB="qemu-conf-${RANDOM}-$$-${RANDOM}"
+TMPB="qemu-conf"
+TMPC="${TMPDIR1}/${TMPB}.c"
TMPO="${TMPDIR1}/${TMPB}.o"
TMPCXX="${TMPDIR1}/${TMPB}.cxx"
TMPL="${TMPDIR1}/${TMPB}.lo"
TMPA="${TMPDIR1}/lib${TMPB}.la"
-TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe"
+TMPE="${TMPDIR1}/${TMPB}.exe"
-# NB: do not call "exit" in the trap handler; this is buggy with some shells;
-# see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
-trap "rm -f $TMPC $TMPO $TMPCXX $TMPE" EXIT INT QUIT TERM
rm -f config.log
# Print a helpful header at the top of config.log
@@ -5235,3 +5237,4 @@ printf " '%s'" "$0" "$@" >>config.status
echo >>config.status
chmod +x config.status
+rm -r "$TMPDIR1"
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-devel] [PULL 11/23] configure: Put tempfiles in a subdir of the build directory
@ 2014-05-26 7:19 ` Michael Tokarev
0 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:19 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Peter Maydell, Michael Tokarev
From: Peter Maydell <peter.maydell@linaro.org>
When libtool support was added to configure, the new temporary files
were left out of the list of files cleaned up on exit; this results
in a lot of stale .lo files being left around in /tmp. Worse, libtool
creates a /tmp/.libs directory which we can't easily clean up.
Put all our temporary files in a single temporary directory created
as a subdirectory of the build directory, so we can easily clean it up,
and don't need fragile or complicated code for creation to avoid it
clashing with temporary directories from other instances of QEMU
configure or being subject to attack from adversaries who can write
to /tmp.
Since the temporaries now live in the build tree, we have no
need to jump through hoops with a trap handler to try to remove
them when configure exits; this fixes some weird bugs where hitting
^C during a configure run wouldn't actually make it stop, because
we would run the trap handler but then not stop. (It is possible
to get the trap handler semantics right but it is convoluted largely
because of bugs in dash, so it is simpler to just avoid it.)
Note that "temporary files go in the build directory, not /tmp" is
the way autoconf behaves.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
.gitignore | 1 +
configure | 29 ++++++++++++++++-------------
2 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/.gitignore b/.gitignore
index 8a52709..c658613 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,6 +4,7 @@
/config-host.*
/config-target.*
/config.status
+/config-temp
/trace/generated-tracers.h
/trace/generated-tracers.c
/trace/generated-tracers-dtrace.h
diff --git a/configure b/configure
index 678a106..cde4325 100755
--- a/configure
+++ b/configure
@@ -2,26 +2,28 @@
#
# qemu configure script (c) 2003 Fabrice Bellard
#
-# set temporary file name
-if test ! -z "$TMPDIR" ; then
- TMPDIR1="${TMPDIR}"
-elif test ! -z "$TEMPDIR" ; then
- TMPDIR1="${TEMPDIR}"
-else
- TMPDIR1="/tmp"
+
+# Temporary directory used for files created while
+# configure runs. Since it is in the build directory
+# we can safely blow away any previous version of it
+# (and we need not jump through hoops to try to delete
+# it when configure exits.)
+TMPDIR1="config-temp"
+rm -rf "${TMPDIR1}"
+mkdir -p "${TMPDIR1}"
+if [ $? -ne 0 ]; then
+ echo "ERROR: failed to create temporary directory"
+ exit 1
fi
-TMPC="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.c"
-TMPB="qemu-conf-${RANDOM}-$$-${RANDOM}"
+TMPB="qemu-conf"
+TMPC="${TMPDIR1}/${TMPB}.c"
TMPO="${TMPDIR1}/${TMPB}.o"
TMPCXX="${TMPDIR1}/${TMPB}.cxx"
TMPL="${TMPDIR1}/${TMPB}.lo"
TMPA="${TMPDIR1}/lib${TMPB}.la"
-TMPE="${TMPDIR1}/qemu-conf-${RANDOM}-$$-${RANDOM}.exe"
+TMPE="${TMPDIR1}/${TMPB}.exe"
-# NB: do not call "exit" in the trap handler; this is buggy with some shells;
-# see <1285349658-3122-1-git-send-email-loic.minier@linaro.org>
-trap "rm -f $TMPC $TMPO $TMPCXX $TMPE" EXIT INT QUIT TERM
rm -f config.log
# Print a helpful header at the top of config.log
@@ -5235,3 +5237,4 @@ printf " '%s'" "$0" "$@" >>config.status
echo >>config.status
chmod +x config.status
+rm -r "$TMPDIR1"
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-trivial] [PULL 12/23] vl: fix 'name' option to work with -readconfig
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
@ 2014-05-26 7:20 ` Michael Tokarev
-1 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:20 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev, Dr. David Alan Gilbert
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
The 'name' option silently failed when used in config files
( http://lists.gnu.org/archive/html/qemu-devel/2014-04/msg00378.html )
-readconfig stores the configuration read in QemuOpts. Command line
option parsing should do the same, and no more. In particular it should
not act upon the option. That needs to be done separately, where both
command line and -readconfig settings are visible in QemuOpts.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reported-by: William Dauchy <william@gandi.net>
Tested-by: William Dauchy <william@gandi.net>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(mjt: added commit message by ambru@ and subject prefix)
---
vl.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/vl.c b/vl.c
index 709d8cd..99b6fc0 100644
--- a/vl.c
+++ b/vl.c
@@ -965,7 +965,7 @@ static int parse_sandbox(QemuOpts *opts, void *opaque)
return 0;
}
-static void parse_name(QemuOpts *opts)
+static int parse_name(QemuOpts *opts, void *opaque)
{
const char *proc_name;
@@ -978,6 +978,8 @@ static void parse_name(QemuOpts *opts)
if (proc_name) {
os_set_proc_name(proc_name);
}
+
+ return 0;
}
bool usb_enabled(bool default_usb)
@@ -3796,7 +3798,6 @@ int main(int argc, char **argv, char **envp)
if (!opts) {
exit(1);
}
- parse_name(opts);
break;
case QEMU_OPTION_prom_env:
if (nb_prom_envs >= MAX_PROM_ENVS) {
@@ -3971,6 +3972,10 @@ int main(int argc, char **argv, char **envp)
exit(1);
}
+ if (qemu_opts_foreach(qemu_find_opts("name"), parse_name, NULL, 1)) {
+ exit(1);
+ }
+
#ifndef _WIN32
if (qemu_opts_foreach(qemu_find_opts("add-fd"), parse_add_fd, NULL, 1)) {
exit(1);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-devel] [PULL 12/23] vl: fix 'name' option to work with -readconfig
@ 2014-05-26 7:20 ` Michael Tokarev
0 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:20 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev, Dr. David Alan Gilbert
From: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
The 'name' option silently failed when used in config files
( http://lists.gnu.org/archive/html/qemu-devel/2014-04/msg00378.html )
-readconfig stores the configuration read in QemuOpts. Command line
option parsing should do the same, and no more. In particular it should
not act upon the option. That needs to be done separately, where both
command line and -readconfig settings are visible in QemuOpts.
Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Reported-by: William Dauchy <william@gandi.net>
Tested-by: William Dauchy <william@gandi.net>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
(mjt: added commit message by ambru@ and subject prefix)
---
vl.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/vl.c b/vl.c
index 709d8cd..99b6fc0 100644
--- a/vl.c
+++ b/vl.c
@@ -965,7 +965,7 @@ static int parse_sandbox(QemuOpts *opts, void *opaque)
return 0;
}
-static void parse_name(QemuOpts *opts)
+static int parse_name(QemuOpts *opts, void *opaque)
{
const char *proc_name;
@@ -978,6 +978,8 @@ static void parse_name(QemuOpts *opts)
if (proc_name) {
os_set_proc_name(proc_name);
}
+
+ return 0;
}
bool usb_enabled(bool default_usb)
@@ -3796,7 +3798,6 @@ int main(int argc, char **argv, char **envp)
if (!opts) {
exit(1);
}
- parse_name(opts);
break;
case QEMU_OPTION_prom_env:
if (nb_prom_envs >= MAX_PROM_ENVS) {
@@ -3971,6 +3972,10 @@ int main(int argc, char **argv, char **envp)
exit(1);
}
+ if (qemu_opts_foreach(qemu_find_opts("name"), parse_name, NULL, 1)) {
+ exit(1);
+ }
+
#ifndef _WIN32
if (qemu_opts_foreach(qemu_find_opts("add-fd"), parse_add_fd, NULL, 1)) {
exit(1);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-trivial] [PULL 13/23] libcacard/vscclient: Bury some dead code
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
@ 2014-05-26 7:20 ` Michael Tokarev
-1 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:20 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev, Markus Armbruster
From: Markus Armbruster <armbru@redhat.com>
Spotted by Coverity.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
libcacard/vscclient.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/libcacard/vscclient.c b/libcacard/vscclient.c
index 3477ab3..29f4958 100644
--- a/libcacard/vscclient.c
+++ b/libcacard/vscclient.c
@@ -502,8 +502,7 @@ do_command(GIOChannel *source,
if (reader != NULL) {
error = vcard_emul_force_card_insert(reader);
printf("insert %s, returned %d\n",
- reader ? vreader_get_name(reader)
- : "invalid reader", error);
+ vreader_get_name(reader), error);
} else {
printf("no reader by id %u found\n", reader_id);
}
@@ -515,8 +514,7 @@ do_command(GIOChannel *source,
if (reader != NULL) {
error = vcard_emul_force_card_remove(reader);
printf("remove %s, returned %d\n",
- reader ? vreader_get_name(reader)
- : "invalid reader", error);
+ vreader_get_name(reader), error);
} else {
printf("no reader by id %u found\n", reader_id);
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-devel] [PULL 13/23] libcacard/vscclient: Bury some dead code
@ 2014-05-26 7:20 ` Michael Tokarev
0 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:20 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev, Markus Armbruster
From: Markus Armbruster <armbru@redhat.com>
Spotted by Coverity.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
libcacard/vscclient.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/libcacard/vscclient.c b/libcacard/vscclient.c
index 3477ab3..29f4958 100644
--- a/libcacard/vscclient.c
+++ b/libcacard/vscclient.c
@@ -502,8 +502,7 @@ do_command(GIOChannel *source,
if (reader != NULL) {
error = vcard_emul_force_card_insert(reader);
printf("insert %s, returned %d\n",
- reader ? vreader_get_name(reader)
- : "invalid reader", error);
+ vreader_get_name(reader), error);
} else {
printf("no reader by id %u found\n", reader_id);
}
@@ -515,8 +514,7 @@ do_command(GIOChannel *source,
if (reader != NULL) {
error = vcard_emul_force_card_remove(reader);
printf("remove %s, returned %d\n",
- reader ? vreader_get_name(reader)
- : "invalid reader", error);
+ vreader_get_name(reader), error);
} else {
printf("no reader by id %u found\n", reader_id);
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-trivial] [PULL 14/23] libcacard: Plug memory leaks around vreader_get_reader_list()
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
@ 2014-05-26 7:20 ` Michael Tokarev
-1 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:20 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev, Markus Armbruster
From: Markus Armbruster <armbru@redhat.com>
Spotted by Coverity.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
libcacard/vcard_emul_nss.c | 4 ++++
libcacard/vscclient.c | 1 +
2 files changed, 5 insertions(+)
diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c
index 75b9d79..7826593 100644
--- a/libcacard/vcard_emul_nss.c
+++ b/libcacard/vcard_emul_nss.c
@@ -433,11 +433,13 @@ vcard_emul_find_vreader_from_slot(PK11SlotInfo *slot)
VReader *reader = vreader_list_get_reader(current_entry);
VReaderEmul *reader_emul = vreader_get_private(reader);
if (reader_emul->slot == slot) {
+ vreader_list_delete(reader_list);
return reader;
}
vreader_free(reader);
}
+ vreader_list_delete(reader_list);
return NULL;
}
@@ -1059,6 +1061,8 @@ vcard_emul_replay_insertion_events(void)
next_entry = vreader_list_get_next(current_entry);
vreader_queue_card_event(vreader);
}
+
+ vreader_list_delete(list);
}
/*
diff --git a/libcacard/vscclient.c b/libcacard/vscclient.c
index 29f4958..f2a753a 100644
--- a/libcacard/vscclient.c
+++ b/libcacard/vscclient.c
@@ -570,6 +570,7 @@ do_command(GIOChannel *source,
"CARD_PRESENT" : " ",
vreader_get_name(reader));
}
+ vreader_list_delete(list);
} else if (*string != 0) {
printf("valid commands:\n");
printf("insert [reader_id]\n");
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-devel] [PULL 14/23] libcacard: Plug memory leaks around vreader_get_reader_list()
@ 2014-05-26 7:20 ` Michael Tokarev
0 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:20 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev, Markus Armbruster
From: Markus Armbruster <armbru@redhat.com>
Spotted by Coverity.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
libcacard/vcard_emul_nss.c | 4 ++++
libcacard/vscclient.c | 1 +
2 files changed, 5 insertions(+)
diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c
index 75b9d79..7826593 100644
--- a/libcacard/vcard_emul_nss.c
+++ b/libcacard/vcard_emul_nss.c
@@ -433,11 +433,13 @@ vcard_emul_find_vreader_from_slot(PK11SlotInfo *slot)
VReader *reader = vreader_list_get_reader(current_entry);
VReaderEmul *reader_emul = vreader_get_private(reader);
if (reader_emul->slot == slot) {
+ vreader_list_delete(reader_list);
return reader;
}
vreader_free(reader);
}
+ vreader_list_delete(reader_list);
return NULL;
}
@@ -1059,6 +1061,8 @@ vcard_emul_replay_insertion_events(void)
next_entry = vreader_list_get_next(current_entry);
vreader_queue_card_event(vreader);
}
+
+ vreader_list_delete(list);
}
/*
diff --git a/libcacard/vscclient.c b/libcacard/vscclient.c
index 29f4958..f2a753a 100644
--- a/libcacard/vscclient.c
+++ b/libcacard/vscclient.c
@@ -570,6 +570,7 @@ do_command(GIOChannel *source,
"CARD_PRESENT" : " ",
vreader_get_name(reader));
}
+ vreader_list_delete(list);
} else if (*string != 0) {
printf("valid commands:\n");
printf("insert [reader_id]\n");
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-trivial] [PULL 15/23] libcacard/vreader: Drop broken recovery from failed assertion
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
@ 2014-05-26 7:20 ` Michael Tokarev
-1 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:20 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev, Markus Armbruster
From: Markus Armbruster <armbru@redhat.com>
We suppress some code when we got unexpected status and assertion
checking is off:
assert(card_status == VCARD_DONE);
if (card_status == VCARD_DONE) {
int size = MIN(*receive_buf_len, response->b_total_len);
memcpy(receive_buf, response->b_data, size);
*receive_buf_len = size;
}
Such "recovery" is of dubious value even when it works. This one
doesn't: it fails to assign to receive_buf[] and *receive_buf_len,
which the callers expect.
Make the code unconditional.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
libcacard/vreader.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/libcacard/vreader.c b/libcacard/vreader.c
index 9304a28..93b01c8 100644
--- a/libcacard/vreader.c
+++ b/libcacard/vreader.c
@@ -284,11 +284,9 @@ vreader_xfr_bytes(VReader *reader,
}
}
assert(card_status == VCARD_DONE);
- if (card_status == VCARD_DONE) {
- int size = MIN(*receive_buf_len, response->b_total_len);
- memcpy(receive_buf, response->b_data, size);
- *receive_buf_len = size;
- }
+ int size = MIN(*receive_buf_len, response->b_total_len);
+ memcpy(receive_buf, response->b_data, size);
+ *receive_buf_len = size;
vcard_response_delete(response);
vcard_apdu_delete(apdu);
vcard_free(card); /* free our reference */
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-devel] [PULL 15/23] libcacard/vreader: Drop broken recovery from failed assertion
@ 2014-05-26 7:20 ` Michael Tokarev
0 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:20 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev, Markus Armbruster
From: Markus Armbruster <armbru@redhat.com>
We suppress some code when we got unexpected status and assertion
checking is off:
assert(card_status == VCARD_DONE);
if (card_status == VCARD_DONE) {
int size = MIN(*receive_buf_len, response->b_total_len);
memcpy(receive_buf, response->b_data, size);
*receive_buf_len = size;
}
Such "recovery" is of dubious value even when it works. This one
doesn't: it fails to assign to receive_buf[] and *receive_buf_len,
which the callers expect.
Make the code unconditional.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
libcacard/vreader.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/libcacard/vreader.c b/libcacard/vreader.c
index 9304a28..93b01c8 100644
--- a/libcacard/vreader.c
+++ b/libcacard/vreader.c
@@ -284,11 +284,9 @@ vreader_xfr_bytes(VReader *reader,
}
}
assert(card_status == VCARD_DONE);
- if (card_status == VCARD_DONE) {
- int size = MIN(*receive_buf_len, response->b_total_len);
- memcpy(receive_buf, response->b_data, size);
- *receive_buf_len = size;
- }
+ int size = MIN(*receive_buf_len, response->b_total_len);
+ memcpy(receive_buf, response->b_data, size);
+ *receive_buf_len = size;
vcard_response_delete(response);
vcard_apdu_delete(apdu);
vcard_free(card); /* free our reference */
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-trivial] [PULL 16/23] libcacard/vreader: Tighten assertion to clarify intent
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
@ 2014-05-26 7:20 ` Michael Tokarev
-1 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:20 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev, Markus Armbruster
From: Markus Armbruster <armbru@redhat.com>
Bonus: hushes up Coverity.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
libcacard/vreader.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcacard/vreader.c b/libcacard/vreader.c
index 93b01c8..f1288d9 100644
--- a/libcacard/vreader.c
+++ b/libcacard/vreader.c
@@ -283,7 +283,7 @@ vreader_xfr_bytes(VReader *reader,
response->b_sw2, response->b_len, response->b_total_len);
}
}
- assert(card_status == VCARD_DONE);
+ assert(card_status == VCARD_DONE && response);
int size = MIN(*receive_buf_len, response->b_total_len);
memcpy(receive_buf, response->b_data, size);
*receive_buf_len = size;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-devel] [PULL 16/23] libcacard/vreader: Tighten assertion to clarify intent
@ 2014-05-26 7:20 ` Michael Tokarev
0 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:20 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev, Markus Armbruster
From: Markus Armbruster <armbru@redhat.com>
Bonus: hushes up Coverity.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
libcacard/vreader.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libcacard/vreader.c b/libcacard/vreader.c
index 93b01c8..f1288d9 100644
--- a/libcacard/vreader.c
+++ b/libcacard/vreader.c
@@ -283,7 +283,7 @@ vreader_xfr_bytes(VReader *reader,
response->b_sw2, response->b_len, response->b_total_len);
}
}
- assert(card_status == VCARD_DONE);
+ assert(card_status == VCARD_DONE && response);
int size = MIN(*receive_buf_len, response->b_total_len);
memcpy(receive_buf, response->b_data, size);
*receive_buf_len = size;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-trivial] [PULL 17/23] libcacard: Convert two leftover realloc() to GLib
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
@ 2014-05-26 7:20 ` Michael Tokarev
-1 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:20 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev, Markus Armbruster
From: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
libcacard/cac.c | 13 ++-----------
libcacard/vcard_emul_nss.c | 7 ++-----
2 files changed, 4 insertions(+), 16 deletions(-)
diff --git a/libcacard/cac.c b/libcacard/cac.c
index 122129e..3887896 100644
--- a/libcacard/cac.c
+++ b/libcacard/cac.c
@@ -169,17 +169,8 @@ cac_applet_pki_process_apdu(VCard *card, VCardAPDU *apdu,
}
size = apdu->a_Lc;
- sign_buffer = realloc(pki_applet->sign_buffer,
- pki_applet->sign_buffer_len+size);
- if (sign_buffer == NULL) {
- g_free(pki_applet->sign_buffer);
- pki_applet->sign_buffer = NULL;
- pki_applet->sign_buffer_len = 0;
- *response = vcard_make_response(
- VCARD7816_STATUS_EXC_ERROR_MEMORY_FAILURE);
- ret = VCARD_DONE;
- break;
- }
+ sign_buffer = g_realloc(pki_applet->sign_buffer,
+ pki_applet->sign_buffer_len + size);
memcpy(sign_buffer+pki_applet->sign_buffer_len, apdu->a_body, size);
size += pki_applet->sign_buffer_len;
switch (apdu->a_p1) {
diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c
index 7826593..8e05551 100644
--- a/libcacard/vcard_emul_nss.c
+++ b/libcacard/vcard_emul_nss.c
@@ -1178,11 +1178,8 @@ vcard_emul_options(const char *args)
if (opts->vreader_count >= reader_count) {
reader_count += READER_STEP;
- vreaderOpt = realloc(opts->vreader,
- reader_count * sizeof(*vreaderOpt));
- if (vreaderOpt == NULL) {
- return opts; /* we're done */
- }
+ vreaderOpt = g_renew(VirtualReaderOptions, opts->vreader,
+ reader_count);
}
opts->vreader = vreaderOpt;
vreaderOpt = &vreaderOpt[opts->vreader_count];
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-devel] [PULL 17/23] libcacard: Convert two leftover realloc() to GLib
@ 2014-05-26 7:20 ` Michael Tokarev
0 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:20 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev, Markus Armbruster
From: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
libcacard/cac.c | 13 ++-----------
libcacard/vcard_emul_nss.c | 7 ++-----
2 files changed, 4 insertions(+), 16 deletions(-)
diff --git a/libcacard/cac.c b/libcacard/cac.c
index 122129e..3887896 100644
--- a/libcacard/cac.c
+++ b/libcacard/cac.c
@@ -169,17 +169,8 @@ cac_applet_pki_process_apdu(VCard *card, VCardAPDU *apdu,
}
size = apdu->a_Lc;
- sign_buffer = realloc(pki_applet->sign_buffer,
- pki_applet->sign_buffer_len+size);
- if (sign_buffer == NULL) {
- g_free(pki_applet->sign_buffer);
- pki_applet->sign_buffer = NULL;
- pki_applet->sign_buffer_len = 0;
- *response = vcard_make_response(
- VCARD7816_STATUS_EXC_ERROR_MEMORY_FAILURE);
- ret = VCARD_DONE;
- break;
- }
+ sign_buffer = g_realloc(pki_applet->sign_buffer,
+ pki_applet->sign_buffer_len + size);
memcpy(sign_buffer+pki_applet->sign_buffer_len, apdu->a_body, size);
size += pki_applet->sign_buffer_len;
switch (apdu->a_p1) {
diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c
index 7826593..8e05551 100644
--- a/libcacard/vcard_emul_nss.c
+++ b/libcacard/vcard_emul_nss.c
@@ -1178,11 +1178,8 @@ vcard_emul_options(const char *args)
if (opts->vreader_count >= reader_count) {
reader_count += READER_STEP;
- vreaderOpt = realloc(opts->vreader,
- reader_count * sizeof(*vreaderOpt));
- if (vreaderOpt == NULL) {
- return opts; /* we're done */
- }
+ vreaderOpt = g_renew(VirtualReaderOptions, opts->vreader,
+ reader_count);
}
opts->vreader = vreaderOpt;
vreaderOpt = &vreaderOpt[opts->vreader_count];
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-trivial] [PULL 18/23] libcacard/vcard_emul_nss: Drop a redundant conditional
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
@ 2014-05-26 7:20 ` Michael Tokarev
-1 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:20 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev, Markus Armbruster
From: Markus Armbruster <armbru@redhat.com>
Bailing out when PK11_FindGenericObjects() returns null ensures the
loop that follows it executes at least once. The "loop did not
execute" test right after it is useless. Drop it.
Spotted by Coverity.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
libcacard/vcard_emul_nss.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c
index 8e05551..b7db51d 100644
--- a/libcacard/vcard_emul_nss.c
+++ b/libcacard/vcard_emul_nss.c
@@ -618,11 +618,6 @@ vcard_emul_mirror_card(VReader *vreader)
cert_count++;
}
- if (cert_count == 0) {
- PK11_DestroyGenericObjects(firstObj);
- return NULL;
- }
-
/* allocate the arrays */
vcard_emul_alloc_arrays(&certs, &cert_len, &keys, cert_count);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-devel] [PULL 18/23] libcacard/vcard_emul_nss: Drop a redundant conditional
@ 2014-05-26 7:20 ` Michael Tokarev
0 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:20 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev, Markus Armbruster
From: Markus Armbruster <armbru@redhat.com>
Bailing out when PK11_FindGenericObjects() returns null ensures the
loop that follows it executes at least once. The "loop did not
execute" test right after it is useless. Drop it.
Spotted by Coverity.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Alon Levy <alevy@redhat.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
libcacard/vcard_emul_nss.c | 5 -----
1 file changed, 5 deletions(-)
diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c
index 8e05551..b7db51d 100644
--- a/libcacard/vcard_emul_nss.c
+++ b/libcacard/vcard_emul_nss.c
@@ -618,11 +618,6 @@ vcard_emul_mirror_card(VReader *vreader)
cert_count++;
}
- if (cert_count == 0) {
- PK11_DestroyGenericObjects(firstObj);
- return NULL;
- }
-
/* allocate the arrays */
vcard_emul_alloc_arrays(&certs, &cert_len, &keys, cert_count);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-trivial] [PULL 19/23] libcacard: fix wrong array expansion logic
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
@ 2014-05-26 7:20 ` Michael Tokarev
-1 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:20 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev
The currrent code in libcacard/vcard_emul_nss.c:vcard_emul_options()
has a weird bug in variable usage around expanding opts->vreader
array.
There's a helper variable, vreaderOpt, which is first needlessly
initialized to NULL, next, conditionally, only we have to expand
opts->vreader, receives array expansion from g_renew(), and next,
even if we don't actually perform expansion, the value of this
variable is assigned to the actual array, opts->vreader, which
was supposed to be expanded.
So, since we expand the array by READER_STEP increments, only
once in READER_STEP (=4) the code will work, in other 3/4 times
it will fail badly.
Fix this by not using this temp variable when expanding the
array, and by dropping the useless =NULL initializer too -
if it wasn't in place initially, compiler would have warned
us about this problem at the beginning.
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
libcacard/vcard_emul_nss.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c
index b7db51d..8462aef 100644
--- a/libcacard/vcard_emul_nss.c
+++ b/libcacard/vcard_emul_nss.c
@@ -1149,7 +1149,7 @@ vcard_emul_options(const char *args)
char type_str[100];
VCardEmulType type;
int count, i;
- VirtualReaderOptions *vreaderOpt = NULL;
+ VirtualReaderOptions *vreaderOpt;
args = strip(args + 5);
if (*args != '(') {
@@ -1173,11 +1173,10 @@ vcard_emul_options(const char *args)
if (opts->vreader_count >= reader_count) {
reader_count += READER_STEP;
- vreaderOpt = g_renew(VirtualReaderOptions, opts->vreader,
- reader_count);
+ opts->vreader = g_renew(VirtualReaderOptions, opts->vreader,
+ reader_count);
}
- opts->vreader = vreaderOpt;
- vreaderOpt = &vreaderOpt[opts->vreader_count];
+ vreaderOpt = &opts->vreader[opts->vreader_count];
vreaderOpt->name = g_strndup(name, name_length);
vreaderOpt->vname = g_strndup(vname, vname_length);
vreaderOpt->card_type = type;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-devel] [PULL 19/23] libcacard: fix wrong array expansion logic
@ 2014-05-26 7:20 ` Michael Tokarev
0 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:20 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev
The currrent code in libcacard/vcard_emul_nss.c:vcard_emul_options()
has a weird bug in variable usage around expanding opts->vreader
array.
There's a helper variable, vreaderOpt, which is first needlessly
initialized to NULL, next, conditionally, only we have to expand
opts->vreader, receives array expansion from g_renew(), and next,
even if we don't actually perform expansion, the value of this
variable is assigned to the actual array, opts->vreader, which
was supposed to be expanded.
So, since we expand the array by READER_STEP increments, only
once in READER_STEP (=4) the code will work, in other 3/4 times
it will fail badly.
Fix this by not using this temp variable when expanding the
array, and by dropping the useless =NULL initializer too -
if it wasn't in place initially, compiler would have warned
us about this problem at the beginning.
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
---
libcacard/vcard_emul_nss.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c
index b7db51d..8462aef 100644
--- a/libcacard/vcard_emul_nss.c
+++ b/libcacard/vcard_emul_nss.c
@@ -1149,7 +1149,7 @@ vcard_emul_options(const char *args)
char type_str[100];
VCardEmulType type;
int count, i;
- VirtualReaderOptions *vreaderOpt = NULL;
+ VirtualReaderOptions *vreaderOpt;
args = strip(args + 5);
if (*args != '(') {
@@ -1173,11 +1173,10 @@ vcard_emul_options(const char *args)
if (opts->vreader_count >= reader_count) {
reader_count += READER_STEP;
- vreaderOpt = g_renew(VirtualReaderOptions, opts->vreader,
- reader_count);
+ opts->vreader = g_renew(VirtualReaderOptions, opts->vreader,
+ reader_count);
}
- opts->vreader = vreaderOpt;
- vreaderOpt = &vreaderOpt[opts->vreader_count];
+ vreaderOpt = &opts->vreader[opts->vreader_count];
vreaderOpt->name = g_strndup(name, name_length);
vreaderOpt->vname = g_strndup(vname, vname_length);
vreaderOpt->card_type = type;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-trivial] [PULL 20/23] audio: replace fprintf(stderr, ...) with error_report() in audio
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
@ 2014-05-26 7:20 ` Michael Tokarev
-1 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:20 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev, Le Tan
From: Le Tan <tamlokveer@gmail.com>
Replace fprintf(stderr,...) with error_report() in files audio/*.
The trailing "\n"s of the @fmt argument have been removed
because @fmt of error_report() should not contain newline.
Signed-off-by: Le Tan <tamlokveer@gmail.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
audio/spiceaudio.c | 2 +-
audio/wavcapture.c | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c
index fceee50..7b79bed 100644
--- a/audio/spiceaudio.c
+++ b/audio/spiceaudio.c
@@ -105,7 +105,7 @@ static int rate_get_samples (struct audio_pcm_info *info, SpiceRateCtl *rate)
bytes = muldiv64 (ticks, info->bytes_per_second, get_ticks_per_sec ());
samples = (bytes - rate->bytes_sent) >> info->shift;
if (samples < 0 || samples > 65536) {
- fprintf (stderr, "Resetting rate control (%" PRId64 " samples)\n", samples);
+ error_report("Resetting rate control (%" PRId64 " samples)", samples);
rate_start (rate);
samples = 0;
}
diff --git a/audio/wavcapture.c b/audio/wavcapture.c
index 9d94623..6f6d792 100644
--- a/audio/wavcapture.c
+++ b/audio/wavcapture.c
@@ -63,8 +63,7 @@ static void wav_destroy (void *opaque)
}
doclose:
if (fclose (wav->f)) {
- fprintf (stderr, "wav_destroy: fclose failed: %s",
- strerror (errno));
+ error_report("wav_destroy: fclose failed: %s", strerror(errno));
}
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-devel] [PULL 20/23] audio: replace fprintf(stderr, ...) with error_report() in audio
@ 2014-05-26 7:20 ` Michael Tokarev
0 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:20 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev, Le Tan
From: Le Tan <tamlokveer@gmail.com>
Replace fprintf(stderr,...) with error_report() in files audio/*.
The trailing "\n"s of the @fmt argument have been removed
because @fmt of error_report() should not contain newline.
Signed-off-by: Le Tan <tamlokveer@gmail.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
audio/spiceaudio.c | 2 +-
audio/wavcapture.c | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/audio/spiceaudio.c b/audio/spiceaudio.c
index fceee50..7b79bed 100644
--- a/audio/spiceaudio.c
+++ b/audio/spiceaudio.c
@@ -105,7 +105,7 @@ static int rate_get_samples (struct audio_pcm_info *info, SpiceRateCtl *rate)
bytes = muldiv64 (ticks, info->bytes_per_second, get_ticks_per_sec ());
samples = (bytes - rate->bytes_sent) >> info->shift;
if (samples < 0 || samples > 65536) {
- fprintf (stderr, "Resetting rate control (%" PRId64 " samples)\n", samples);
+ error_report("Resetting rate control (%" PRId64 " samples)", samples);
rate_start (rate);
samples = 0;
}
diff --git a/audio/wavcapture.c b/audio/wavcapture.c
index 9d94623..6f6d792 100644
--- a/audio/wavcapture.c
+++ b/audio/wavcapture.c
@@ -63,8 +63,7 @@ static void wav_destroy (void *opaque)
}
doclose:
if (fclose (wav->f)) {
- fprintf (stderr, "wav_destroy: fclose failed: %s",
- strerror (errno));
+ error_report("wav_destroy: fclose failed: %s", strerror(errno));
}
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-trivial] [PULL 21/23] bsd-user: replace fprintf(stderr, ...) with error_report()
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
@ 2014-05-26 7:20 ` Michael Tokarev
-1 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:20 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev, Le Tan
From: Le Tan <tamlokveer@gmail.com>
Replace fprintf(stderr,...) with error_report() in files bsd-user/*.
The trailing "\n"s of the @fmt argument have been removed
because @fmt of error_report() should not contain newline.
Signed-off-by: Le Tan <tamlokveer@gmail.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
bsd-user/bsdload.c | 2 +-
bsd-user/elfload.c | 2 +-
bsd-user/main.c | 14 +++++++-------
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/bsd-user/bsdload.c b/bsd-user/bsdload.c
index 2abc713..6b52e08 100644
--- a/bsd-user/bsdload.c
+++ b/bsd-user/bsdload.c
@@ -183,7 +183,7 @@ int loader_exec(const char * filename, char ** argv, char ** envp,
&& bprm.buf[3] == 'F') {
retval = load_elf_binary(&bprm,regs,infop);
} else {
- fprintf(stderr, "Unknown binary format\n");
+ error_report("Unknown binary format");
return -1;
}
}
diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c
index 93fd9e4..95652b1 100644
--- a/bsd-user/elfload.c
+++ b/bsd-user/elfload.c
@@ -628,7 +628,7 @@ static abi_ulong copy_elf_strings(int argc,char ** argv, void **page,
while (argc-- > 0) {
tmp = argv[argc];
if (!tmp) {
- fprintf(stderr, "VFS: argc is wrong");
+ error_report("VFS: argc is wrong");
exit(-1);
}
tmp1 = tmp;
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 4ba61da..de74d17 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -378,8 +378,8 @@ void cpu_loop(CPUX86State *env)
#endif
default:
pc = env->segs[R_CS].base + env->eip;
- fprintf(stderr, "qemu: 0x%08lx: unhandled CPU exception 0x%x - aborting\n",
- (long)pc, trapnr);
+ error_report("qemu: 0x%08lx: unhandled CPU exception 0x%x"
+ " - aborting", (long)pc, trapnr);
abort();
}
process_pending_signals(env);
@@ -752,7 +752,7 @@ int main(int argc, char **argv)
module_call_init(MODULE_INIT_QOM);
if ((envlist = envlist_create()) == NULL) {
- (void) fprintf(stderr, "Unable to allocate envlist\n");
+ error_report("Unable to allocate envlist");
exit(1);
}
@@ -794,7 +794,7 @@ int main(int argc, char **argv)
} else if (!strcmp(r, "ignore-environment")) {
envlist_free(envlist);
if ((envlist = envlist_create()) == NULL) {
- (void) fprintf(stderr, "Unable to allocate envlist\n");
+ error_report("Unable to allocate envlist");
exit(1);
}
} else if (!strcmp(r, "U")) {
@@ -816,7 +816,7 @@ int main(int argc, char **argv)
qemu_host_page_size = atoi(argv[optind++]);
if (qemu_host_page_size == 0 ||
(qemu_host_page_size & (qemu_host_page_size - 1)) != 0) {
- fprintf(stderr, "page size must be a power of two\n");
+ error_report("page size must be a power of two");
exit(1);
}
} else if (!strcmp(r, "g")) {
@@ -910,7 +910,7 @@ int main(int argc, char **argv)
qemu_host_page_size */
env = cpu_init(cpu_model);
if (!env) {
- fprintf(stderr, "Unable to find CPU definition\n");
+ error_report("Unable to find CPU definition");
exit(1);
}
cpu = ENV_GET_CPU(env);
@@ -1012,7 +1012,7 @@ int main(int argc, char **argv)
#ifndef TARGET_ABI32
/* enable 64 bit mode if possible */
if (!(env->features[FEAT_8000_0001_EDX] & CPUID_EXT2_LM)) {
- fprintf(stderr, "The selected x86 CPU does not support 64 bit mode\n");
+ error_report("The selected x86 CPU does not support 64 bit mode");
exit(1);
}
env->cr[4] |= CR4_PAE_MASK;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-devel] [PULL 21/23] bsd-user: replace fprintf(stderr, ...) with error_report()
@ 2014-05-26 7:20 ` Michael Tokarev
0 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:20 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev, Le Tan
From: Le Tan <tamlokveer@gmail.com>
Replace fprintf(stderr,...) with error_report() in files bsd-user/*.
The trailing "\n"s of the @fmt argument have been removed
because @fmt of error_report() should not contain newline.
Signed-off-by: Le Tan <tamlokveer@gmail.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
bsd-user/bsdload.c | 2 +-
bsd-user/elfload.c | 2 +-
bsd-user/main.c | 14 +++++++-------
3 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/bsd-user/bsdload.c b/bsd-user/bsdload.c
index 2abc713..6b52e08 100644
--- a/bsd-user/bsdload.c
+++ b/bsd-user/bsdload.c
@@ -183,7 +183,7 @@ int loader_exec(const char * filename, char ** argv, char ** envp,
&& bprm.buf[3] == 'F') {
retval = load_elf_binary(&bprm,regs,infop);
} else {
- fprintf(stderr, "Unknown binary format\n");
+ error_report("Unknown binary format");
return -1;
}
}
diff --git a/bsd-user/elfload.c b/bsd-user/elfload.c
index 93fd9e4..95652b1 100644
--- a/bsd-user/elfload.c
+++ b/bsd-user/elfload.c
@@ -628,7 +628,7 @@ static abi_ulong copy_elf_strings(int argc,char ** argv, void **page,
while (argc-- > 0) {
tmp = argv[argc];
if (!tmp) {
- fprintf(stderr, "VFS: argc is wrong");
+ error_report("VFS: argc is wrong");
exit(-1);
}
tmp1 = tmp;
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 4ba61da..de74d17 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -378,8 +378,8 @@ void cpu_loop(CPUX86State *env)
#endif
default:
pc = env->segs[R_CS].base + env->eip;
- fprintf(stderr, "qemu: 0x%08lx: unhandled CPU exception 0x%x - aborting\n",
- (long)pc, trapnr);
+ error_report("qemu: 0x%08lx: unhandled CPU exception 0x%x"
+ " - aborting", (long)pc, trapnr);
abort();
}
process_pending_signals(env);
@@ -752,7 +752,7 @@ int main(int argc, char **argv)
module_call_init(MODULE_INIT_QOM);
if ((envlist = envlist_create()) == NULL) {
- (void) fprintf(stderr, "Unable to allocate envlist\n");
+ error_report("Unable to allocate envlist");
exit(1);
}
@@ -794,7 +794,7 @@ int main(int argc, char **argv)
} else if (!strcmp(r, "ignore-environment")) {
envlist_free(envlist);
if ((envlist = envlist_create()) == NULL) {
- (void) fprintf(stderr, "Unable to allocate envlist\n");
+ error_report("Unable to allocate envlist");
exit(1);
}
} else if (!strcmp(r, "U")) {
@@ -816,7 +816,7 @@ int main(int argc, char **argv)
qemu_host_page_size = atoi(argv[optind++]);
if (qemu_host_page_size == 0 ||
(qemu_host_page_size & (qemu_host_page_size - 1)) != 0) {
- fprintf(stderr, "page size must be a power of two\n");
+ error_report("page size must be a power of two");
exit(1);
}
} else if (!strcmp(r, "g")) {
@@ -910,7 +910,7 @@ int main(int argc, char **argv)
qemu_host_page_size */
env = cpu_init(cpu_model);
if (!env) {
- fprintf(stderr, "Unable to find CPU definition\n");
+ error_report("Unable to find CPU definition");
exit(1);
}
cpu = ENV_GET_CPU(env);
@@ -1012,7 +1012,7 @@ int main(int argc, char **argv)
#ifndef TARGET_ABI32
/* enable 64 bit mode if possible */
if (!(env->features[FEAT_8000_0001_EDX] & CPUID_EXT2_LM)) {
- fprintf(stderr, "The selected x86 CPU does not support 64 bit mode\n");
+ error_report("The selected x86 CPU does not support 64 bit mode");
exit(1);
}
env->cr[4] |= CR4_PAE_MASK;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-trivial] [PULL 22/23] net: cadence_gem: Fix top comment
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
@ 2014-05-26 7:20 ` Michael Tokarev
-1 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:20 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Peter Crosthwaite, Michael Tokarev
From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
To indicate Cadence GEM not Xilinx.
Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
hw/net/cadence_gem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
index 47e7038..a26861e 100644
--- a/hw/net/cadence_gem.c
+++ b/hw/net/cadence_gem.c
@@ -1,5 +1,5 @@
/*
- * QEMU Xilinx GEM emulation
+ * QEMU Cadence GEM emulation
*
* Copyright (c) 2011 Xilinx, Inc.
*
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-devel] [PULL 22/23] net: cadence_gem: Fix top comment
@ 2014-05-26 7:20 ` Michael Tokarev
0 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:20 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Peter Crosthwaite, Michael Tokarev
From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
To indicate Cadence GEM not Xilinx.
Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
hw/net/cadence_gem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/net/cadence_gem.c b/hw/net/cadence_gem.c
index 47e7038..a26861e 100644
--- a/hw/net/cadence_gem.c
+++ b/hw/net/cadence_gem.c
@@ -1,5 +1,5 @@
/*
- * QEMU Xilinx GEM emulation
+ * QEMU Cadence GEM emulation
*
* Copyright (c) 2011 Xilinx, Inc.
*
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-trivial] [PULL 23/23] libcacard: remove useless initializers
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
@ 2014-05-26 7:20 ` Michael Tokarev
-1 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:20 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev
libcacard has many functions which initializes local variables
at declaration time, which are always assigned some values later
(often right after declaration). Clean up these initializers.
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
libcacard/cac.c | 14 +++++++-------
libcacard/card_7816.c | 5 ++---
libcacard/vcard.c | 4 ++--
libcacard/vcard_emul_nss.c | 6 +++---
libcacard/vreader.c | 10 +++++-----
libcacard/vscclient.c | 4 ++--
6 files changed, 21 insertions(+), 22 deletions(-)
diff --git a/libcacard/cac.c b/libcacard/cac.c
index 3887896..0a0163d 100644
--- a/libcacard/cac.c
+++ b/libcacard/cac.c
@@ -93,8 +93,8 @@ cac_common_process_apdu(VCard *card, VCardAPDU *apdu, VCardResponse **response)
static VCardStatus
cac_applet_pki_reset(VCard *card, int channel)
{
- VCardAppletPrivate *applet_private = NULL;
- CACPKIAppletData *pki_applet = NULL;
+ VCardAppletPrivate *applet_private;
+ CACPKIAppletData *pki_applet;
applet_private = vcard_get_current_applet_private(card, channel);
assert(applet_private);
pki_applet = &(applet_private->u.pki_data);
@@ -113,8 +113,8 @@ static VCardStatus
cac_applet_pki_process_apdu(VCard *card, VCardAPDU *apdu,
VCardResponse **response)
{
- CACPKIAppletData *pki_applet = NULL;
- VCardAppletPrivate *applet_private = NULL;
+ CACPKIAppletData *pki_applet;
+ VCardAppletPrivate *applet_private;
int size, next;
unsigned char *sign_buffer;
vcard_7816_status_t status;
@@ -279,7 +279,7 @@ cac_applet_container_process_apdu(VCard *card, VCardAPDU *apdu,
static void
cac_delete_pki_applet_private(VCardAppletPrivate *applet_private)
{
- CACPKIAppletData *pki_applet_data = NULL;
+ CACPKIAppletData *pki_applet_data;
if (applet_private == NULL) {
return;
@@ -327,8 +327,8 @@ static VCardApplet *
cac_new_pki_applet(int i, const unsigned char *cert,
int cert_len, VCardKey *key)
{
- VCardAppletPrivate *applet_private = NULL;
- VCardApplet *applet = NULL;
+ VCardAppletPrivate *applet_private;
+ VCardApplet *applet;
unsigned char pki_aid[] = { 0xa0, 0x00, 0x00, 0x00, 0x79, 0x01, 0x00 };
int pki_aid_len = sizeof(pki_aid);
diff --git a/libcacard/card_7816.c b/libcacard/card_7816.c
index bca8c4a..a54f880 100644
--- a/libcacard/card_7816.c
+++ b/libcacard/card_7816.c
@@ -416,7 +416,7 @@ VCARD_RESPONSE_NEW_STATIC_STATUS(VCARD7816_STATUS_ERROR_GENERAL)
VCardResponse *
vcard_make_response(vcard_7816_status_t status)
{
- VCardResponse *response = NULL;
+ VCardResponse *response;
switch (status) {
/* known 7816 response codes */
@@ -543,9 +543,8 @@ vcard_make_response(vcard_7816_status_t status)
return VCARD_RESPONSE_GET_STATIC(
VCARD7816_STATUS_EXC_ERROR_MEMORY_FAILURE);
}
+ return response;
}
- assert(response);
- return response;
}
/*
diff --git a/libcacard/vcard.c b/libcacard/vcard.c
index 227e477..6aaf085 100644
--- a/libcacard/vcard.c
+++ b/libcacard/vcard.c
@@ -166,8 +166,8 @@ vcard_reference(VCard *vcard)
void
vcard_free(VCard *vcard)
{
- VCardApplet *current_applet = NULL;
- VCardApplet *next_applet = NULL;
+ VCardApplet *current_applet;
+ VCardApplet *next_applet;
if (vcard == NULL) {
return;
diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c
index 8462aef..cefc383 100644
--- a/libcacard/vcard_emul_nss.c
+++ b/libcacard/vcard_emul_nss.c
@@ -367,7 +367,7 @@ vcard_7816_status_t
vcard_emul_login(VCard *card, unsigned char *pin, int pin_len)
{
PK11SlotInfo *slot;
- unsigned char *pin_string = NULL;
+ unsigned char *pin_string;
int i;
SECStatus rv;
@@ -423,7 +423,7 @@ static VReader *
vcard_emul_find_vreader_from_slot(PK11SlotInfo *slot)
{
VReaderList *reader_list = vreader_get_reader_list();
- VReaderListEntry *current_entry = NULL;
+ VReaderListEntry *current_entry;
if (reader_list == NULL) {
return NULL;
@@ -1047,7 +1047,7 @@ void
vcard_emul_replay_insertion_events(void)
{
VReaderListEntry *current_entry;
- VReaderListEntry *next_entry = NULL;
+ VReaderListEntry *next_entry;
VReaderList *list = vreader_get_reader_list();
for (current_entry = vreader_list_get_first(list); current_entry;
diff --git a/libcacard/vreader.c b/libcacard/vreader.c
index f1288d9..d2a9b7d 100644
--- a/libcacard/vreader.c
+++ b/libcacard/vreader.c
@@ -339,7 +339,7 @@ void
vreader_list_delete(VReaderList *list)
{
VReaderListEntry *current_entry;
- VReaderListEntry *next_entry = NULL;
+ VReaderListEntry *next_entry;
for (current_entry = vreader_list_get_first(list); current_entry;
current_entry = next_entry) {
next_entry = vreader_list_get_next(current_entry);
@@ -430,8 +430,8 @@ vreader_list_unlock(void)
static VReaderList *
vreader_copy_list(VReaderList *list)
{
- VReaderList *new_list = NULL;
- VReaderListEntry *current_entry = NULL;
+ VReaderList *new_list;
+ VReaderListEntry *current_entry;
new_list = vreader_list_new();
if (new_list == NULL) {
@@ -463,7 +463,7 @@ VReader *
vreader_get_reader_by_id(vreader_id_t id)
{
VReader *reader = NULL;
- VReaderListEntry *current_entry = NULL;
+ VReaderListEntry *current_entry;
if (id == (vreader_id_t) -1) {
return NULL;
@@ -487,7 +487,7 @@ VReader *
vreader_get_reader_by_name(const char *name)
{
VReader *reader = NULL;
- VReaderListEntry *current_entry = NULL;
+ VReaderListEntry *current_entry;
vreader_list_lock();
for (current_entry = vreader_list_get_first(vreader_list); current_entry;
diff --git a/libcacard/vscclient.c b/libcacard/vscclient.c
index f2a753a..6693900 100644
--- a/libcacard/vscclient.c
+++ b/libcacard/vscclient.c
@@ -131,8 +131,8 @@ static void *
event_thread(void *arg)
{
unsigned char atr[MAX_ATR_LEN];
- int atr_len = MAX_ATR_LEN;
- VEvent *event = NULL;
+ int atr_len;
+ VEvent *event;
unsigned int reader_id;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* [Qemu-devel] [PULL 23/23] libcacard: remove useless initializers
@ 2014-05-26 7:20 ` Michael Tokarev
0 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-05-26 7:20 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-trivial, Michael Tokarev
libcacard has many functions which initializes local variables
at declaration time, which are always assigned some values later
(often right after declaration). Clean up these initializers.
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
---
libcacard/cac.c | 14 +++++++-------
libcacard/card_7816.c | 5 ++---
libcacard/vcard.c | 4 ++--
libcacard/vcard_emul_nss.c | 6 +++---
libcacard/vreader.c | 10 +++++-----
libcacard/vscclient.c | 4 ++--
6 files changed, 21 insertions(+), 22 deletions(-)
diff --git a/libcacard/cac.c b/libcacard/cac.c
index 3887896..0a0163d 100644
--- a/libcacard/cac.c
+++ b/libcacard/cac.c
@@ -93,8 +93,8 @@ cac_common_process_apdu(VCard *card, VCardAPDU *apdu, VCardResponse **response)
static VCardStatus
cac_applet_pki_reset(VCard *card, int channel)
{
- VCardAppletPrivate *applet_private = NULL;
- CACPKIAppletData *pki_applet = NULL;
+ VCardAppletPrivate *applet_private;
+ CACPKIAppletData *pki_applet;
applet_private = vcard_get_current_applet_private(card, channel);
assert(applet_private);
pki_applet = &(applet_private->u.pki_data);
@@ -113,8 +113,8 @@ static VCardStatus
cac_applet_pki_process_apdu(VCard *card, VCardAPDU *apdu,
VCardResponse **response)
{
- CACPKIAppletData *pki_applet = NULL;
- VCardAppletPrivate *applet_private = NULL;
+ CACPKIAppletData *pki_applet;
+ VCardAppletPrivate *applet_private;
int size, next;
unsigned char *sign_buffer;
vcard_7816_status_t status;
@@ -279,7 +279,7 @@ cac_applet_container_process_apdu(VCard *card, VCardAPDU *apdu,
static void
cac_delete_pki_applet_private(VCardAppletPrivate *applet_private)
{
- CACPKIAppletData *pki_applet_data = NULL;
+ CACPKIAppletData *pki_applet_data;
if (applet_private == NULL) {
return;
@@ -327,8 +327,8 @@ static VCardApplet *
cac_new_pki_applet(int i, const unsigned char *cert,
int cert_len, VCardKey *key)
{
- VCardAppletPrivate *applet_private = NULL;
- VCardApplet *applet = NULL;
+ VCardAppletPrivate *applet_private;
+ VCardApplet *applet;
unsigned char pki_aid[] = { 0xa0, 0x00, 0x00, 0x00, 0x79, 0x01, 0x00 };
int pki_aid_len = sizeof(pki_aid);
diff --git a/libcacard/card_7816.c b/libcacard/card_7816.c
index bca8c4a..a54f880 100644
--- a/libcacard/card_7816.c
+++ b/libcacard/card_7816.c
@@ -416,7 +416,7 @@ VCARD_RESPONSE_NEW_STATIC_STATUS(VCARD7816_STATUS_ERROR_GENERAL)
VCardResponse *
vcard_make_response(vcard_7816_status_t status)
{
- VCardResponse *response = NULL;
+ VCardResponse *response;
switch (status) {
/* known 7816 response codes */
@@ -543,9 +543,8 @@ vcard_make_response(vcard_7816_status_t status)
return VCARD_RESPONSE_GET_STATIC(
VCARD7816_STATUS_EXC_ERROR_MEMORY_FAILURE);
}
+ return response;
}
- assert(response);
- return response;
}
/*
diff --git a/libcacard/vcard.c b/libcacard/vcard.c
index 227e477..6aaf085 100644
--- a/libcacard/vcard.c
+++ b/libcacard/vcard.c
@@ -166,8 +166,8 @@ vcard_reference(VCard *vcard)
void
vcard_free(VCard *vcard)
{
- VCardApplet *current_applet = NULL;
- VCardApplet *next_applet = NULL;
+ VCardApplet *current_applet;
+ VCardApplet *next_applet;
if (vcard == NULL) {
return;
diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c
index 8462aef..cefc383 100644
--- a/libcacard/vcard_emul_nss.c
+++ b/libcacard/vcard_emul_nss.c
@@ -367,7 +367,7 @@ vcard_7816_status_t
vcard_emul_login(VCard *card, unsigned char *pin, int pin_len)
{
PK11SlotInfo *slot;
- unsigned char *pin_string = NULL;
+ unsigned char *pin_string;
int i;
SECStatus rv;
@@ -423,7 +423,7 @@ static VReader *
vcard_emul_find_vreader_from_slot(PK11SlotInfo *slot)
{
VReaderList *reader_list = vreader_get_reader_list();
- VReaderListEntry *current_entry = NULL;
+ VReaderListEntry *current_entry;
if (reader_list == NULL) {
return NULL;
@@ -1047,7 +1047,7 @@ void
vcard_emul_replay_insertion_events(void)
{
VReaderListEntry *current_entry;
- VReaderListEntry *next_entry = NULL;
+ VReaderListEntry *next_entry;
VReaderList *list = vreader_get_reader_list();
for (current_entry = vreader_list_get_first(list); current_entry;
diff --git a/libcacard/vreader.c b/libcacard/vreader.c
index f1288d9..d2a9b7d 100644
--- a/libcacard/vreader.c
+++ b/libcacard/vreader.c
@@ -339,7 +339,7 @@ void
vreader_list_delete(VReaderList *list)
{
VReaderListEntry *current_entry;
- VReaderListEntry *next_entry = NULL;
+ VReaderListEntry *next_entry;
for (current_entry = vreader_list_get_first(list); current_entry;
current_entry = next_entry) {
next_entry = vreader_list_get_next(current_entry);
@@ -430,8 +430,8 @@ vreader_list_unlock(void)
static VReaderList *
vreader_copy_list(VReaderList *list)
{
- VReaderList *new_list = NULL;
- VReaderListEntry *current_entry = NULL;
+ VReaderList *new_list;
+ VReaderListEntry *current_entry;
new_list = vreader_list_new();
if (new_list == NULL) {
@@ -463,7 +463,7 @@ VReader *
vreader_get_reader_by_id(vreader_id_t id)
{
VReader *reader = NULL;
- VReaderListEntry *current_entry = NULL;
+ VReaderListEntry *current_entry;
if (id == (vreader_id_t) -1) {
return NULL;
@@ -487,7 +487,7 @@ VReader *
vreader_get_reader_by_name(const char *name)
{
VReader *reader = NULL;
- VReaderListEntry *current_entry = NULL;
+ VReaderListEntry *current_entry;
vreader_list_lock();
for (current_entry = vreader_list_get_first(vreader_list); current_entry;
diff --git a/libcacard/vscclient.c b/libcacard/vscclient.c
index f2a753a..6693900 100644
--- a/libcacard/vscclient.c
+++ b/libcacard/vscclient.c
@@ -131,8 +131,8 @@ static void *
event_thread(void *arg)
{
unsigned char atr[MAX_ATR_LEN];
- int atr_len = MAX_ATR_LEN;
- VEvent *event = NULL;
+ int atr_len;
+ VEvent *event;
unsigned int reader_id;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 58+ messages in thread
* Re: [Qemu-trivial] [Qemu-devel] [PULL 00/23] Trivial patches for 2014-05-26
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
` (23 preceding siblings ...)
(?)
@ 2014-05-27 22:30 ` Peter Maydell
-1 siblings, 0 replies; 58+ messages in thread
From: Peter Maydell @ 2014-05-27 22:30 UTC (permalink / raw)
To: Michael Tokarev; +Cc: QEMU Trivial, QEMU Developers
On 26 May 2014 08:19, Michael Tokarev <mjt@tls.msk.ru> wrote:
> Here's another trivial patches pull request.
>
> This time it accumulated 23 patches, in many areas, with a focus,
> for some reason, on libcacard, which received quite some cleanups
> and a fix for a fun bug.
>
> More interesting changes this time are by Peter Maydell, -- these
> are the bswap.h macros renaming and using a subdir in curdir for
> temporaries.
>
> Please consider applying.
>
> /mjt
>
> The following changes since commit 6054d883d6138bfc92c73a7c090c824b64086fd2:
>
> Merge remote-tracking branch 'remotes/kraxel/tags/pull-chardev-2' into staging (2014-05-22 18:14:01 +0100)
>
> are available in the git repository at:
>
>
> git://git.corpit.ru/qemu.git tags/trivial-patches-2014-05-26
>
> for you to fetch changes up to 1687a089f103f9b7a1b4a1555068054cb46ee9e9:
>
> libcacard: remove useless initializers (2014-05-26 10:41:22 +0400)
>
> ----------------------------------------------------------------
> trivial patches for 2014-05-26
>
Applied, thanks.
-- PMM
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [Qemu-trivial] [Qemu-devel] [PULL 21/23] bsd-user: replace fprintf(stderr, ...) with error_report()
2014-05-26 7:20 ` [Qemu-devel] " Michael Tokarev
(?)
@ 2014-05-31 22:39 ` Peter Maydell
2014-06-02 12:08 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2014-06-02 13:09 ` Markus Armbruster
-1 siblings, 2 replies; 58+ messages in thread
From: Peter Maydell @ 2014-05-31 22:39 UTC (permalink / raw)
To: Michael Tokarev; +Cc: QEMU Trivial, QEMU Developers, Le Tan
On 26 May 2014 08:20, Michael Tokarev <mjt@tls.msk.ru> wrote:
> From: Le Tan <tamlokveer@gmail.com>
>
> Replace fprintf(stderr,...) with error_report() in files bsd-user/*.
> The trailing "\n"s of the @fmt argument have been removed
> because @fmt of error_report() should not contain newline.
>
> Signed-off-by: Le Tan <tamlokveer@gmail.com>
> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Was this patch tested? Building on FreeBSD the compiler
complains:
"warning: implicit declaration of function 'error_report' is invalid in C99"
because none of these bsd-user files include a header which
gives a prototype for error_report. Also, these are just
straightforward reporting of command line errors, and I
think that, like the linux-user code, we should handle
these in the obvious way by printing to stderr. There's no
need to drag in the error-handling framework for this,
especially since user-mode doesn't have the "maybe we
need to send this to the monitor" issues system emulation
does.
In short, I think we need to revert this commit
(1fba509527beb).
thanks
-- PMM
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [Qemu-trivial] [Qemu-devel] [PULL 21/23] bsd-user: replace fprintf(stderr, ...) with error_report()
2014-05-31 22:39 ` [Qemu-trivial] " Peter Maydell
@ 2014-06-02 12:08 ` Michael Tokarev
2014-06-02 13:09 ` Markus Armbruster
1 sibling, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-06-02 12:08 UTC (permalink / raw)
To: Peter Maydell; +Cc: QEMU Trivial, QEMU Developers, Le Tan
01.06.2014 02:39, Peter Maydell wrote:
> On 26 May 2014 08:20, Michael Tokarev <mjt@tls.msk.ru> wrote:
>> From: Le Tan <tamlokveer@gmail.com>
>>
>> Replace fprintf(stderr,...) with error_report() in files bsd-user/*.
>> The trailing "\n"s of the @fmt argument have been removed
>> because @fmt of error_report() should not contain newline.
>>
>> Signed-off-by: Le Tan <tamlokveer@gmail.com>
>> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
>
> Was this patch tested? Building on FreeBSD the compiler
> complains:
> "warning: implicit declaration of function 'error_report' is invalid in C99"
>
> because none of these bsd-user files include a header which
> gives a prototype for error_report. Also, these are just
> straightforward reporting of command line errors, and I
> think that, like the linux-user code, we should handle
> these in the obvious way by printing to stderr. There's no
> need to drag in the error-handling framework for this,
> especially since user-mode doesn't have the "maybe we
> need to send this to the monitor" issues system emulation
> does.
Umm. it is a Very Good call.
I applied it and actually tried to compile-check it, on kFreeBSD.
Compile went successfully, and I was satisfied, until I figured
that my kFreeBSD test script only builds qemu-system. So I went
back and enabled this, and actually found the issue and even
fixed it locally, by adding the #includes. While doing this, I
wondered, why such a basic/common subsystem is not included in
there to start with, and so isn't used? Maybe this is something
which shouldn't be done?
But I got distracted from all this due to other issues, and when
I come back I just pushed the whole thing without noticing the
added #includes aren't committed, and forgetting about my doubts.
That's what you get when doing stuff in a hurry.
> In short, I think we need to revert this commit
> (1fba509527beb).
Yes, that's what I think too. Should I send a formal patch
submission, or is `git revert' easy enough? Even with my
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
if needed?
Thanks,
/mjt
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [Qemu-devel] [Qemu-trivial] [PULL 21/23] bsd-user: replace fprintf(stderr, ...) with error_report()
@ 2014-06-02 12:08 ` Michael Tokarev
0 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-06-02 12:08 UTC (permalink / raw)
To: Peter Maydell; +Cc: QEMU Trivial, QEMU Developers, Le Tan
01.06.2014 02:39, Peter Maydell wrote:
> On 26 May 2014 08:20, Michael Tokarev <mjt@tls.msk.ru> wrote:
>> From: Le Tan <tamlokveer@gmail.com>
>>
>> Replace fprintf(stderr,...) with error_report() in files bsd-user/*.
>> The trailing "\n"s of the @fmt argument have been removed
>> because @fmt of error_report() should not contain newline.
>>
>> Signed-off-by: Le Tan <tamlokveer@gmail.com>
>> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
>
> Was this patch tested? Building on FreeBSD the compiler
> complains:
> "warning: implicit declaration of function 'error_report' is invalid in C99"
>
> because none of these bsd-user files include a header which
> gives a prototype for error_report. Also, these are just
> straightforward reporting of command line errors, and I
> think that, like the linux-user code, we should handle
> these in the obvious way by printing to stderr. There's no
> need to drag in the error-handling framework for this,
> especially since user-mode doesn't have the "maybe we
> need to send this to the monitor" issues system emulation
> does.
Umm. it is a Very Good call.
I applied it and actually tried to compile-check it, on kFreeBSD.
Compile went successfully, and I was satisfied, until I figured
that my kFreeBSD test script only builds qemu-system. So I went
back and enabled this, and actually found the issue and even
fixed it locally, by adding the #includes. While doing this, I
wondered, why such a basic/common subsystem is not included in
there to start with, and so isn't used? Maybe this is something
which shouldn't be done?
But I got distracted from all this due to other issues, and when
I come back I just pushed the whole thing without noticing the
added #includes aren't committed, and forgetting about my doubts.
That's what you get when doing stuff in a hurry.
> In short, I think we need to revert this commit
> (1fba509527beb).
Yes, that's what I think too. Should I send a formal patch
submission, or is `git revert' easy enough? Even with my
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
if needed?
Thanks,
/mjt
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [Qemu-trivial] [Qemu-devel] [PULL 21/23] bsd-user: replace fprintf(stderr, ...) with error_report()
2014-06-02 12:08 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
@ 2014-06-02 12:34 ` Peter Maydell
-1 siblings, 0 replies; 58+ messages in thread
From: Peter Maydell @ 2014-06-02 12:34 UTC (permalink / raw)
To: Michael Tokarev; +Cc: QEMU Trivial, QEMU Developers, Le Tan
On 2 June 2014 13:08, Michael Tokarev <mjt@tls.msk.ru> wrote:
> I applied it and actually tried to compile-check it, on kFreeBSD.
> Compile went successfully, and I was satisfied, until I figured
> that my kFreeBSD test script only builds qemu-system. So I went
> back and enabled this, and actually found the issue and even
> fixed it locally, by adding the #includes. While doing this, I
> wondered, why such a basic/common subsystem is not included in
> there to start with, and so isn't used? Maybe this is something
> which shouldn't be done?
I think it's not inherently wrong to use the error-reporting
infrastructure -- the *-user targets historically were very
much "only use the CPU emulation stuff", but they've gradually
accumulated more use of generic QEMU utility routines, especially
with the advent of QOM. But if we want to do that then we should
probably start with the linux-user code, which gets much more
testing, and only convert bsd-user when we're happy that it
doesn't have any unexpected issues. (Especially since bsd-user
as it stands is badly broken; I'd like to encourage the BSD folks
who are currently working on landing fixes and improvements to
it, so I'd prefer not to give them unnecessary extra rebasing
and merge-conflict resolution work by churning the current
mainline code too much.)
>> In short, I think we need to revert this commit
>> (1fba509527beb).
>
> Yes, that's what I think too. Should I send a formal patch
> submission, or is `git revert' easy enough? Even with my
> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
> if needed?
I'll just do a git-revert, with your acked-by, and push it
to master.
thanks
-- PMM
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [Qemu-devel] [Qemu-trivial] [PULL 21/23] bsd-user: replace fprintf(stderr, ...) with error_report()
@ 2014-06-02 12:34 ` Peter Maydell
0 siblings, 0 replies; 58+ messages in thread
From: Peter Maydell @ 2014-06-02 12:34 UTC (permalink / raw)
To: Michael Tokarev; +Cc: QEMU Trivial, QEMU Developers, Le Tan
On 2 June 2014 13:08, Michael Tokarev <mjt@tls.msk.ru> wrote:
> I applied it and actually tried to compile-check it, on kFreeBSD.
> Compile went successfully, and I was satisfied, until I figured
> that my kFreeBSD test script only builds qemu-system. So I went
> back and enabled this, and actually found the issue and even
> fixed it locally, by adding the #includes. While doing this, I
> wondered, why such a basic/common subsystem is not included in
> there to start with, and so isn't used? Maybe this is something
> which shouldn't be done?
I think it's not inherently wrong to use the error-reporting
infrastructure -- the *-user targets historically were very
much "only use the CPU emulation stuff", but they've gradually
accumulated more use of generic QEMU utility routines, especially
with the advent of QOM. But if we want to do that then we should
probably start with the linux-user code, which gets much more
testing, and only convert bsd-user when we're happy that it
doesn't have any unexpected issues. (Especially since bsd-user
as it stands is badly broken; I'd like to encourage the BSD folks
who are currently working on landing fixes and improvements to
it, so I'd prefer not to give them unnecessary extra rebasing
and merge-conflict resolution work by churning the current
mainline code too much.)
>> In short, I think we need to revert this commit
>> (1fba509527beb).
>
> Yes, that's what I think too. Should I send a formal patch
> submission, or is `git revert' easy enough? Even with my
> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
> if needed?
I'll just do a git-revert, with your acked-by, and push it
to master.
thanks
-- PMM
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [Qemu-trivial] [Qemu-devel] [PULL 21/23] bsd-user: replace fprintf(stderr, ...) with error_report()
2014-05-31 22:39 ` [Qemu-trivial] " Peter Maydell
@ 2014-06-02 13:09 ` Markus Armbruster
2014-06-02 13:09 ` Markus Armbruster
1 sibling, 0 replies; 58+ messages in thread
From: Markus Armbruster @ 2014-06-02 13:09 UTC (permalink / raw)
To: Peter Maydell; +Cc: QEMU Trivial, Michael Tokarev, QEMU Developers, Le Tan
Peter Maydell <peter.maydell@linaro.org> writes:
> On 26 May 2014 08:20, Michael Tokarev <mjt@tls.msk.ru> wrote:
>> From: Le Tan <tamlokveer@gmail.com>
>>
>> Replace fprintf(stderr,...) with error_report() in files bsd-user/*.
>> The trailing "\n"s of the @fmt argument have been removed
>> because @fmt of error_report() should not contain newline.
>>
>> Signed-off-by: Le Tan <tamlokveer@gmail.com>
>> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
>
> Was this patch tested? Building on FreeBSD the compiler
> complains:
> "warning: implicit declaration of function 'error_report' is invalid in C99"
>
> because none of these bsd-user files include a header which
> gives a prototype for error_report. Also, these are just
> straightforward reporting of command line errors, and I
> think that, like the linux-user code, we should handle
> these in the obvious way by printing to stderr. There's no
> need to drag in the error-handling framework for this,
> especially since user-mode doesn't have the "maybe we
> need to send this to the monitor" issues system emulation
> does.
Not much of a "framework", really.
Even in straightforward command line cases, error_report() adds value,
namely a uniform error message format that includes the program name.
Its ability to point to the offending option is useful when the command
line gets long (and ours are prone to get really, really long).
Especially useful when -readconfig comes into play (config file
bisection is no fun). Unfortunately, the location information can get
lost on its way from option parsing to option use, but that's just
carelessness on our part.
> In short, I think we need to revert this commit
> (1fba509527beb).
Not my bikeshed to paint; do what you think is best.
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [Qemu-devel] [PULL 21/23] bsd-user: replace fprintf(stderr, ...) with error_report()
@ 2014-06-02 13:09 ` Markus Armbruster
0 siblings, 0 replies; 58+ messages in thread
From: Markus Armbruster @ 2014-06-02 13:09 UTC (permalink / raw)
To: Peter Maydell; +Cc: QEMU Trivial, Michael Tokarev, QEMU Developers, Le Tan
Peter Maydell <peter.maydell@linaro.org> writes:
> On 26 May 2014 08:20, Michael Tokarev <mjt@tls.msk.ru> wrote:
>> From: Le Tan <tamlokveer@gmail.com>
>>
>> Replace fprintf(stderr,...) with error_report() in files bsd-user/*.
>> The trailing "\n"s of the @fmt argument have been removed
>> because @fmt of error_report() should not contain newline.
>>
>> Signed-off-by: Le Tan <tamlokveer@gmail.com>
>> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
>
> Was this patch tested? Building on FreeBSD the compiler
> complains:
> "warning: implicit declaration of function 'error_report' is invalid in C99"
>
> because none of these bsd-user files include a header which
> gives a prototype for error_report. Also, these are just
> straightforward reporting of command line errors, and I
> think that, like the linux-user code, we should handle
> these in the obvious way by printing to stderr. There's no
> need to drag in the error-handling framework for this,
> especially since user-mode doesn't have the "maybe we
> need to send this to the monitor" issues system emulation
> does.
Not much of a "framework", really.
Even in straightforward command line cases, error_report() adds value,
namely a uniform error message format that includes the program name.
Its ability to point to the offending option is useful when the command
line gets long (and ours are prone to get really, really long).
Especially useful when -readconfig comes into play (config file
bisection is no fun). Unfortunately, the location information can get
lost on its way from option parsing to option use, but that's just
carelessness on our part.
> In short, I think we need to revert this commit
> (1fba509527beb).
Not my bikeshed to paint; do what you think is best.
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [Qemu-trivial] [Qemu-devel] [PULL 21/23] bsd-user: replace fprintf(stderr, ...) with error_report()
2014-06-02 13:09 ` Markus Armbruster
@ 2014-06-02 13:16 ` Michael Tokarev
-1 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-06-02 13:16 UTC (permalink / raw)
To: Markus Armbruster, Peter Maydell; +Cc: QEMU Trivial, QEMU Developers, Le Tan
02.06.2014 17:09, Markus Armbruster wrote:
> Peter Maydell <peter.maydell@linaro.org> writes:
[]
>> because none of these bsd-user files include a header which
>> gives a prototype for error_report. Also, these are just
>> straightforward reporting of command line errors, and I
>> think that, like the linux-user code, we should handle
>> these in the obvious way by printing to stderr. There's no
>> need to drag in the error-handling framework for this,
>> especially since user-mode doesn't have the "maybe we
>> need to send this to the monitor" issues system emulation
>> does.
>
> Not much of a "framework", really.
>
> Even in straightforward command line cases, error_report() adds value,
> namely a uniform error message format that includes the program name.
> Its ability to point to the offending option is useful when the command
> line gets long (and ours are prone to get really, really long).
Please note the talk is about bsd-USER, not a SYSTEM emulation.
And for -user. the command line is usually just the opposite - very
short, consisting of the original command line with qemu-foo prepended.
When I encountered this phenomenon (lack of any #includes declaring
error_report()) I thought that maybe an alternative channel for error
reporting might be useful there, like QEMU_LOG=$TMPDIR/foo qemu-foo ...,
so that the output produced by qemu can be separated from the output
produced by the program it runs, but just as Peter pointed out, we're
far from there yet, and indeed, we should start elsewhere.
Thanks,
/mjt
^ permalink raw reply [flat|nested] 58+ messages in thread
* Re: [Qemu-devel] [PULL 21/23] bsd-user: replace fprintf(stderr, ...) with error_report()
@ 2014-06-02 13:16 ` Michael Tokarev
0 siblings, 0 replies; 58+ messages in thread
From: Michael Tokarev @ 2014-06-02 13:16 UTC (permalink / raw)
To: Markus Armbruster, Peter Maydell; +Cc: QEMU Trivial, QEMU Developers, Le Tan
02.06.2014 17:09, Markus Armbruster wrote:
> Peter Maydell <peter.maydell@linaro.org> writes:
[]
>> because none of these bsd-user files include a header which
>> gives a prototype for error_report. Also, these are just
>> straightforward reporting of command line errors, and I
>> think that, like the linux-user code, we should handle
>> these in the obvious way by printing to stderr. There's no
>> need to drag in the error-handling framework for this,
>> especially since user-mode doesn't have the "maybe we
>> need to send this to the monitor" issues system emulation
>> does.
>
> Not much of a "framework", really.
>
> Even in straightforward command line cases, error_report() adds value,
> namely a uniform error message format that includes the program name.
> Its ability to point to the offending option is useful when the command
> line gets long (and ours are prone to get really, really long).
Please note the talk is about bsd-USER, not a SYSTEM emulation.
And for -user. the command line is usually just the opposite - very
short, consisting of the original command line with qemu-foo prepended.
When I encountered this phenomenon (lack of any #includes declaring
error_report()) I thought that maybe an alternative channel for error
reporting might be useful there, like QEMU_LOG=$TMPDIR/foo qemu-foo ...,
so that the output produced by qemu can be separated from the output
produced by the program it runs, but just as Peter pointed out, we're
far from there yet, and indeed, we should start elsewhere.
Thanks,
/mjt
^ permalink raw reply [flat|nested] 58+ messages in thread
end of thread, other threads:[~2014-06-02 13:16 UTC | newest]
Thread overview: 58+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-26 7:19 [Qemu-trivial] [PULL 00/23] Trivial patches for 2014-05-26 Michael Tokarev
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
2014-05-26 7:19 ` [Qemu-trivial] [PULL 01/23] libcacard: g_malloc cleanups Michael Tokarev
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
2014-05-26 7:19 ` [Qemu-trivial] [PULL 02/23] iohandler.c: Properly initialize sigaction struct Michael Tokarev
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
2014-05-26 7:19 ` [Qemu-trivial] [PULL 03/23] nbd: Close socket on negotiation failure Michael Tokarev
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
2014-05-26 7:19 ` [Qemu-trivial] [PULL 04/23] nbd: Miscellaneous typo fixes Michael Tokarev
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
2014-05-26 7:19 ` [Qemu-trivial] [PULL 05/23] configure: Automatically select GTK+ 3.0 if GTK+ 2.0 is unavailable Michael Tokarev
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
2014-05-26 7:19 ` [Qemu-trivial] [PULL 06/23] bswap.h: Rename ldl_p, stl_p, etc to ldl_he_p, stl_he_p, etc Michael Tokarev
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
2014-05-26 7:19 ` [Qemu-trivial] [PULL 07/23] jazz_led: Add missing break in switch case Michael Tokarev
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
2014-05-26 7:19 ` [Qemu-trivial] [PULL 08/23] pci: move dereferencing of root only after verifying valid root pointer Michael Tokarev
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
2014-05-26 7:19 ` [Qemu-trivial] [PULL 09/23] arch_init: replace fprintf(stderr, ...) with error_report() Michael Tokarev
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
2014-05-26 7:19 ` [Qemu-trivial] [PULL 10/23] dma-helpers: avoid calling dma_bdrv_unmap() twice Michael Tokarev
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
2014-05-26 7:19 ` [Qemu-trivial] [PULL 11/23] configure: Put tempfiles in a subdir of the build directory Michael Tokarev
2014-05-26 7:19 ` [Qemu-devel] " Michael Tokarev
2014-05-26 7:20 ` [Qemu-trivial] [PULL 12/23] vl: fix 'name' option to work with -readconfig Michael Tokarev
2014-05-26 7:20 ` [Qemu-devel] " Michael Tokarev
2014-05-26 7:20 ` [Qemu-trivial] [PULL 13/23] libcacard/vscclient: Bury some dead code Michael Tokarev
2014-05-26 7:20 ` [Qemu-devel] " Michael Tokarev
2014-05-26 7:20 ` [Qemu-trivial] [PULL 14/23] libcacard: Plug memory leaks around vreader_get_reader_list() Michael Tokarev
2014-05-26 7:20 ` [Qemu-devel] " Michael Tokarev
2014-05-26 7:20 ` [Qemu-trivial] [PULL 15/23] libcacard/vreader: Drop broken recovery from failed assertion Michael Tokarev
2014-05-26 7:20 ` [Qemu-devel] " Michael Tokarev
2014-05-26 7:20 ` [Qemu-trivial] [PULL 16/23] libcacard/vreader: Tighten assertion to clarify intent Michael Tokarev
2014-05-26 7:20 ` [Qemu-devel] " Michael Tokarev
2014-05-26 7:20 ` [Qemu-trivial] [PULL 17/23] libcacard: Convert two leftover realloc() to GLib Michael Tokarev
2014-05-26 7:20 ` [Qemu-devel] " Michael Tokarev
2014-05-26 7:20 ` [Qemu-trivial] [PULL 18/23] libcacard/vcard_emul_nss: Drop a redundant conditional Michael Tokarev
2014-05-26 7:20 ` [Qemu-devel] " Michael Tokarev
2014-05-26 7:20 ` [Qemu-trivial] [PULL 19/23] libcacard: fix wrong array expansion logic Michael Tokarev
2014-05-26 7:20 ` [Qemu-devel] " Michael Tokarev
2014-05-26 7:20 ` [Qemu-trivial] [PULL 20/23] audio: replace fprintf(stderr, ...) with error_report() in audio Michael Tokarev
2014-05-26 7:20 ` [Qemu-devel] " Michael Tokarev
2014-05-26 7:20 ` [Qemu-trivial] [PULL 21/23] bsd-user: replace fprintf(stderr, ...) with error_report() Michael Tokarev
2014-05-26 7:20 ` [Qemu-devel] " Michael Tokarev
2014-05-31 22:39 ` [Qemu-trivial] " Peter Maydell
2014-06-02 12:08 ` Michael Tokarev
2014-06-02 12:08 ` [Qemu-devel] [Qemu-trivial] " Michael Tokarev
2014-06-02 12:34 ` [Qemu-trivial] [Qemu-devel] " Peter Maydell
2014-06-02 12:34 ` [Qemu-devel] [Qemu-trivial] " Peter Maydell
2014-06-02 13:09 ` [Qemu-trivial] [Qemu-devel] " Markus Armbruster
2014-06-02 13:09 ` Markus Armbruster
2014-06-02 13:16 ` [Qemu-trivial] " Michael Tokarev
2014-06-02 13:16 ` Michael Tokarev
2014-05-26 7:20 ` [Qemu-trivial] [PULL 22/23] net: cadence_gem: Fix top comment Michael Tokarev
2014-05-26 7:20 ` [Qemu-devel] " Michael Tokarev
2014-05-26 7:20 ` [Qemu-trivial] [PULL 23/23] libcacard: remove useless initializers Michael Tokarev
2014-05-26 7:20 ` [Qemu-devel] " Michael Tokarev
2014-05-27 22:30 ` [Qemu-trivial] [Qemu-devel] [PULL 00/23] Trivial patches for 2014-05-26 Peter Maydell
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.