Patchwork Make NICInfo string fields non-const

login
register
mail settings
Submitter Mark McLoughlin
Date Oct. 6, 2009, 11:16 a.m.
Message ID <1254827836-11021-4-git-send-email-markmc@redhat.com>
Download mbox | patch
Permalink /patch/35084/
State Superseded
Headers show

Comments

Mark McLoughlin - Oct. 6, 2009, 11:16 a.m.
We now only assign strdup()ed strings to these fields, never static
strings.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
---
 net.c |    8 ++++----
 net.h |    8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)
Anthony Liguori - Oct. 6, 2009, 7:19 p.m.
Mark McLoughlin wrote:
> We now only assign strdup()ed strings to these fields, never static
> strings.
>
> Signed-off-by: Mark McLoughlin <markmc@redhat.com>
>   

This breaks the build because of a literal assignment in mips_jazz.c.

Regards,

Anthony Liguori
>      void *private;
>

Patch

diff --git a/net.c b/net.c
index f2b954c..76e44c9 100644
--- a/net.c
+++ b/net.c
@@ -2813,10 +2813,10 @@  void net_client_uninit(NICInfo *nd)
     nd->vlan->nb_guest_devs--;
     nb_nics--;
 
-    qemu_free((void *)nd->model);
-    qemu_free((void *)nd->name);
-    qemu_free((void *)nd->devaddr);
-    qemu_free((void *)nd->id);
+    qemu_free(nd->model);
+    qemu_free(nd->name);
+    qemu_free(nd->devaddr);
+    qemu_free(nd->id);
 
     memset(nd, 0, sizeof(*nd));
 }
diff --git a/net.h b/net.h
index dfce8d6..a36df45 100644
--- a/net.h
+++ b/net.h
@@ -95,10 +95,10 @@  enum {
 
 struct NICInfo {
     uint8_t macaddr[6];
-    const char *model;
-    const char *name;
-    const char *devaddr;
-    const char *id;
+    char *model;
+    char *name;
+    char *devaddr;
+    char *id;
     VLANState *vlan;
     VLANClientState *vc;
     void *private;