diff mbox series

[1/2,v3] usb-mtp: remove usb_mtp_object_free_one

Message ID 20190328173722.26465-2-bsd@redhat.com (mailing list archive)
State New, archived
Headers show
Series misc usb-mtp fixes | expand

Commit Message

Bandan Das March 28, 2019, 5:37 p.m. UTC
This function is used in the delete path only and can
be replaced by a call to usb_mtp_object_free.

Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Bandan Das <bsd@redhat.com>
---
 hw/usb/dev-mtp.c | 14 ++------------
 1 file changed, 2 insertions(+), 12 deletions(-)

Comments

Gerd Hoffmann April 1, 2019, 6:56 a.m. UTC | #1
On Thu, Mar 28, 2019 at 01:37:21PM -0400, Bandan Das wrote:
> This function is used in the delete path only and can
> be replaced by a call to usb_mtp_object_free.
> 
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Bandan Das <bsd@redhat.com>

Tried to cherry-pick this one for 4.0 (I think we should leave 2/2 to
4.1 at this point).  Doesn't apply to master, seems to depend on a
not-yet merged patch.  Can you re-post this one and the depending patch
please?

thanks,
  Gerd
Bandan Das April 1, 2019, 9:19 p.m. UTC | #2
Gerd Hoffmann <kraxel@redhat.com> writes:

> On Thu, Mar 28, 2019 at 01:37:21PM -0400, Bandan Das wrote:
>> This function is used in the delete path only and can
>> be replaced by a call to usb_mtp_object_free.
>> 
>> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
>> Signed-off-by: Bandan Das <bsd@redhat.com>
>
> Tried to cherry-pick this one for 4.0 (I think we should leave 2/2 to
> 4.1 at this point).  Doesn't apply to master, seems to depend on a
> not-yet merged patch.  Can you re-post this one and the depending patch
> please?
>

Posted a v4, message-id: <20190401211712.19012-1-bsd@redhat.com>
I forgot to skip 3/3, but I will remember to post it again as a single
patch if it's easier for you that way.

Bandan

> thanks,
>   Gerd
diff mbox series

Patch

diff --git a/hw/usb/dev-mtp.c b/hw/usb/dev-mtp.c
index 91b820baaf..4dc1317e2e 100644
--- a/hw/usb/dev-mtp.c
+++ b/hw/usb/dev-mtp.c
@@ -1150,16 +1150,6 @@  enum {
     DELETE_PARTIAL = (DELETE_FAILURE | DELETE_SUCCESS),
 };
 
-/* Assumes that children, if any, have been already freed */
-static void usb_mtp_object_free_one(MTPState *s, MTPObject *o)
-{
-    assert(o->nchildren == 0);
-    QTAILQ_REMOVE(&s->objects, o, next);
-    g_free(o->name);
-    g_free(o->path);
-    g_free(o);
-}
-
 static int usb_mtp_deletefn(MTPState *s, MTPObject *o, uint32_t trans)
 {
     MTPObject *iter, *iter2;
@@ -1181,14 +1171,14 @@  static int usb_mtp_deletefn(MTPState *s, MTPObject *o, uint32_t trans)
         if (remove(o->path)) {
             ret |= DELETE_FAILURE;
         } else {
-            usb_mtp_object_free_one(s, o);
+            usb_mtp_object_free(s, o);
             ret |= DELETE_SUCCESS;
         }
     } else if (o->format == FMT_ASSOCIATION) {
         if (rmdir(o->path)) {
             ret |= DELETE_FAILURE;
         } else {
-            usb_mtp_object_free_one(s, o);
+            usb_mtp_object_free(s, o);
             ret |= DELETE_SUCCESS;
         }
     }