qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Andrzej Zaborowski <balrogg@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [5651] Revert r5532, r5536 and a piece of r5531.
Date: Sat, 08 Nov 2008 23:57:26 +0000	[thread overview]
Message-ID: <E1KyxgE-00048e-LW@cvs.savannah.gnu.org> (raw)

Revision: 5651
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=5651
Author:   balrog
Date:     2008-11-08 23:57:26 +0000 (Sat, 08 Nov 2008)

Log Message:
-----------
Revert r5532, r5536 and a piece of r5531.

The use of strncat and strndup was correct, pstrcpy and pstrdup wasn't.
I'll try to restore building on non-gnu OSes in a later commit.

Modified Paths:
--------------
    trunk/cutils.c
    trunk/hw/bt-hci.c
    trunk/qemu-common.h

Modified: trunk/cutils.c
===================================================================
--- trunk/cutils.c	2008-11-08 16:27:07 UTC (rev 5650)
+++ trunk/cutils.c	2008-11-08 23:57:26 UTC (rev 5651)
@@ -50,18 +50,6 @@
     return buf;
 }
 
-/* strdup with a limit */
-char *pstrdup(const char *str, size_t buf_size)
-{
-    size_t len;
-    char *buf;
-
-    len = MIN(buf_size, strlen(str));
-    buf = qemu_malloc(len);
-    pstrcpy(buf, len, str);
-    return buf;
-}
-
 int strstart(const char *str, const char *val, const char **ptr)
 {
     const char *p, *q;

Modified: trunk/hw/bt-hci.c
===================================================================
--- trunk/hw/bt-hci.c	2008-11-08 16:27:07 UTC (rev 5650)
+++ trunk/hw/bt-hci.c	2008-11-08 23:57:26 UTC (rev 5651)
@@ -1137,7 +1137,7 @@
     hci->device.inquiry_scan = 0;
     hci->device.page_scan = 0;
     if (hci->device.lmp_name)
-        qemu_free((void *) hci->device.lmp_name);
+        free((void *) hci->device.lmp_name);
     hci->device.lmp_name = 0;
     hci->device.class[0] = 0x00;
     hci->device.class[1] = 0x00;
@@ -1387,7 +1387,7 @@
     params.status = HCI_SUCCESS;
     memset(params.name, 0, sizeof(params.name));
     if (hci->device.lmp_name)
-        pstrcpy(params.name, sizeof(params.name), hci->device.lmp_name);
+        strncpy(params.name, hci->device.lmp_name, sizeof(params.name));
 
     bt_hci_event_complete(hci, &params, READ_LOCAL_NAME_RP_SIZE);
 }
@@ -1815,8 +1815,8 @@
         LENGTH_CHECK(change_local_name);
 
         if (hci->device.lmp_name)
-            qemu_free((void *) hci->device.lmp_name);
-        hci->device.lmp_name = pstrdup(PARAM(change_local_name, name),
+            free((void *) hci->device.lmp_name);
+        hci->device.lmp_name = strndup(PARAM(change_local_name, name),
                         sizeof(PARAM(change_local_name, name)));
         bt_hci_event_complete_status(hci, HCI_SUCCESS);
         break;
@@ -2191,7 +2191,7 @@
     bt_device_done(&hci->device);
 
     if (hci->device.lmp_name)
-        qemu_free((void *) hci->device.lmp_name);
+        free((void *) hci->device.lmp_name);
 
     /* Be gentle and send DISCONNECT to all connected peers and those
      * currently waiting for us to accept or reject a connection request.

Modified: trunk/qemu-common.h
===================================================================
--- trunk/qemu-common.h	2008-11-08 16:27:07 UTC (rev 5650)
+++ trunk/qemu-common.h	2008-11-08 23:57:26 UTC (rev 5651)
@@ -89,7 +89,6 @@
 /* cutils.c */
 void pstrcpy(char *buf, int buf_size, const char *str);
 char *pstrcat(char *buf, int buf_size, const char *s);
-char *pstrdup(const char *str, size_t buf_size);
 int strstart(const char *str, const char *val, const char **ptr);
 int stristart(const char *str, const char *val, const char **ptr);
 time_t mktimegm(struct tm *tm);

                 reply	other threads:[~2008-11-08 23:57 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1KyxgE-00048e-LW@cvs.savannah.gnu.org \
    --to=balrogg@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).