Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.1/patches/2229707/?format=api
{ "id": 2229707, "url": "http://patchwork.ozlabs.org/api/1.1/patches/2229707/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260428162048.2995097-1-luc.fast2004@gmail.com/", "project": { "id": 14, "url": "http://patchwork.ozlabs.org/api/1.1/projects/14/?format=api", "name": "QEMU Development", "link_name": "qemu-devel", "list_id": "qemu-devel.nongnu.org", "list_email": "qemu-devel@nongnu.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20260428162048.2995097-1-luc.fast2004@gmail.com>", "date": "2026-04-28T16:20:48", "name": "[v2] hw/audio/fmopl.c: Convert malloc, free to g_malloc0, g_new and g_free", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "4fbe8a61dfa8f19c7508d6d0c3380949731a6617", "submitter": { "id": 93266, "url": "http://patchwork.ozlabs.org/api/1.1/people/93266/?format=api", "name": "Lucas Cardoso", "email": "luc.fast2004@gmail.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260428162048.2995097-1-luc.fast2004@gmail.com/mbox/", "series": [ { "id": 501895, "url": "http://patchwork.ozlabs.org/api/1.1/series/501895/?format=api", "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=501895", "date": "2026-04-28T16:20:48", "name": "[v2] hw/audio/fmopl.c: Convert malloc, free to g_malloc0, g_new and g_free", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/501895/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2229707/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2229707/checks/", "tags": {}, "headers": { "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=dDl/hCH3;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists1p.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)" ], "Received": [ "from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g4m0N0Bj5z1xrS\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 29 Apr 2026 02:21:40 +1000 (AEST)", "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists1p.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wHlBR-0001vC-Rn; Tue, 28 Apr 2026 12:21:13 -0400", "from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <luc.fast2004@gmail.com>)\n id 1wHlBQ-0001uZ-Cj\n for qemu-devel@nongnu.org; Tue, 28 Apr 2026 12:21:12 -0400", "from mail-yx1-xb136.google.com ([2607:f8b0:4864:20::b136])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)\n (Exim 4.90_1) (envelope-from <luc.fast2004@gmail.com>)\n id 1wHlBO-0006yl-Ow\n for qemu-devel@nongnu.org; Tue, 28 Apr 2026 12:21:12 -0400", "by mail-yx1-xb136.google.com with SMTP id\n 956f58d0204a3-64e87a81639so10586490d50.0\n for <qemu-devel@nongnu.org>; Tue, 28 Apr 2026 09:21:10 -0700 (PDT)", "from lucas-Vivobook-S14.ufscar.br\n ([2801:b0:20:59:e35a:fdf0:bf7c:590a])\n by smtp.gmail.com with ESMTPSA id\n 956f58d0204a3-65bee29f1b4sm2099215d50.5.2026.04.28.09.21.06\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 28 Apr 2026 09:21:09 -0700 (PDT)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=gmail.com; s=20251104; t=1777393269; x=1777998069; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:from:to:cc:subject:date:message-id:reply-to;\n bh=CKPpYdl5J5ki2kTMbn/T2wAohH8knYa1gzHgRuUyn5U=;\n b=dDl/hCH3lVZehl9+AgDCuBd5kR9NTcYRTqtMS0sc8hYrYwt7j+qLsts6miZ/OEwCSe\n RRb6B/3aR7q9rkk6qx9HdX5Hze0TqLdWdzcX8kltCB3hnz+0HApml7LOCISsjc9ONZzA\n jx2VKY59Yt+vHQ8vpxGR1uEjWbHUWMPdxIx6oo1KXF7KrZn8eljkHtZb4hDvc+Re506W\n ljHgLk1id7k1TGsBF61dSzXx3j+prm96B59Ipp8ZU7B3oWXhzRvOsGHaGWJ8UEMMpGLn\n GGYgLQfaK2FGoaCZYmfTBafUQ0k57nJiIgNi5jfKNg2B02dg7RSibo44TrnudPxNUFxl\n fh/Q==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1777393269; x=1777998069;\n h=content-transfer-encoding:mime-version:message-id:date:subject:cc\n :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date\n :message-id:reply-to;\n bh=CKPpYdl5J5ki2kTMbn/T2wAohH8knYa1gzHgRuUyn5U=;\n b=rD/YwjkwDi7D4QzMNlFWpFVvrOHqFQtzZhKpxKS72QQyb4ytDi2n7LRorkrYr2xxoF\n 7obn8upQdCe5y7X0jeum+8oX3edIywc1StaSR765AMR7jsSfD6K3ADGs1nSoWsvnFlqe\n VvLIcNwOOhGz+HsB8FdGSwdfl8pljgjWtpQKqDabgzShvAYAjBqON4jAkYS7hljkDAiB\n UL0pGxJyeEbGYT64Uu7R8Ijre94anbXcPEDcXJhgnUXrWvb3n6kpQ3rEJFhqgelCIbVv\n H5JRHZOzgiqTpgPKb+Iqh7Y1WTkIbgGUPlofTa0gVlNVXsd0XlHnKrQvnSsrfa5mx2lJ\n lqKw==", "X-Gm-Message-State": "AOJu0Yw5ApqtLVW1deqhtH5kotDryiGjbYSDPmk9bVaDQAathElL9B5d\n qEH59mZRrJsN/s//KXRuffGc5Z3sBRFeQ9XvF1RUkVwxA1EVkjBExpqMgMZwnPB5", "X-Gm-Gg": "AeBDievu+LS+MRv7RUaHZEOAujZAW9ypXMaU+7TJNd8BcTrY1q2JeyxHT+oupz3cT+E\n TYbpbb5cWJseIgC/SKtAefOtMAI/jwN5jK8kRN3S4R1NIvxsqwce5ebwbrCOat2tXZwfYziWFiD\n h8hK8tXbVr2zwBfjdQ1F0HjI5Y86gYh7UuXPnFVfsFlApKWXX32bAFrCIiAVBqJ2WiiMogtTvOq\n dYy3UE5K641IM0BvhvFl3jCvQ+2cFsfn7iiRt+cZV0ekGxkynTZeCGXyk7uc8tENtwTHRTUzJ5i\n 9FZZ5lz03rpNb4LBn4ox/+cTr4CCfo0eCyvSWLm1z2SVbwHfqCfnvnkL7uhB0uz1FfklGOFUjzU\n W1lt0h3RE9ly6sdEzdFkO/2hwg5iK3bVgfOaG8TckgB6AQ39wX+ei5PERSzEXSJhJX+mgQO//gy\n CEFOg42jRmK4sLNLM3VVEIqUQoa/QbFcinHJlwwdtonGlP8TIjP82IVZZB", "X-Received": "by 2002:a53:de0f:0:b0:652:ec6c:e2ea with SMTP id\n 956f58d0204a3-65bfb7051f4mr306082d50.50.1777393269452;\n Tue, 28 Apr 2026 09:21:09 -0700 (PDT)", "From": "Lucas Cardoso <luc.fast2004@gmail.com>", "To": "qemu-devel@nongnu.org", "Cc": "kraxel@redhat.com, qemu-trivial@nongnu.org, marcandre.lureau@redhat.com,\n Lucas Cardoso <luc.fast2004@gmail.com>", "Subject": "[PATCH v2] hw/audio/fmopl.c: Convert malloc, free to g_malloc0,\n g_new and g_free", "Date": "Tue, 28 Apr 2026 13:20:48 -0300", "Message-ID": "<20260428162048.2995097-1-luc.fast2004@gmail.com>", "X-Mailer": "git-send-email 2.51.0", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Received-SPF": "pass client-ip=2607:f8b0:4864:20::b136;\n envelope-from=luc.fast2004@gmail.com; helo=mail-yx1-xb136.google.com", "X-Spam_score_int": "-17", "X-Spam_score": "-1.8", "X-Spam_bar": "-", "X-Spam_report": "(-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001,\n RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,\n SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no", "X-Spam_action": "no action", "X-BeenThere": "qemu-devel@nongnu.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "qemu development <qemu-devel.nongnu.org>", "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>", "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>", "List-Post": "<mailto:qemu-devel@nongnu.org>", "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>", "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>", "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org", "Sender": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org" }, "content": "In accordance with QEMU's coding style guidelines, replace raw memory\nallocation functions (malloc/free) with their GLib equivalents\n(g_new/g_malloc0/g_free/g_clear_pointer).\n\nAlso removes the old generic error-handling code from\nOPLOpenTable(), since the Glib functions abort the program automatically\nif memory is exhausted.\n\nResolves: https://gitlab.com/qemu-project/qemu/-/work_items/1798\nReviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>\nSigned-off-by: Lucas Cardoso <luc.fast2004@gmail.com>\n---\nv2: \n- After some studying, I decided to follow Marc-André's feedback to use g_clear_pointer() instead of g_free(), on the OPLCloseTable function.\n hw/audio/fmopl.c | 43 ++++++++++++-------------------------------\n 1 file changed, 12 insertions(+), 31 deletions(-)", "diff": "diff --git a/hw/audio/fmopl.c b/hw/audio/fmopl.c\nindex a63ad0f04d..91fe806fd6 100644\n--- a/hw/audio/fmopl.c\n+++ b/hw/audio/fmopl.c\n@@ -607,26 +607,10 @@ static int OPLOpenTable( void )\n \tdouble pom;\n \n \t/* allocate dynamic tables */\n-\tif( (TL_TABLE = malloc(TL_MAX*2*sizeof(int32_t))) == NULL)\n-\t\treturn 0;\n-\tif( (SIN_TABLE = malloc(SIN_ENT*4 *sizeof(int32_t *))) == NULL)\n-\t{\n-\t\tfree(TL_TABLE);\n-\t\treturn 0;\n-\t}\n-\tif( (AMS_TABLE = malloc(AMS_ENT*2 *sizeof(int32_t))) == NULL)\n-\t{\n-\t\tfree(TL_TABLE);\n-\t\tfree(SIN_TABLE);\n-\t\treturn 0;\n-\t}\n-\tif( (VIB_TABLE = malloc(VIB_ENT*2 *sizeof(int32_t))) == NULL)\n-\t{\n-\t\tfree(TL_TABLE);\n-\t\tfree(SIN_TABLE);\n-\t\tfree(AMS_TABLE);\n-\t\treturn 0;\n-\t}\n+ TL_TABLE = g_new(int32_t, TL_MAX * 2);\n+ SIN_TABLE = g_new(int32_t *, SIN_ENT * 4);\n+ AMS_TABLE = g_new(int32_t, AMS_ENT * 2);\n+ VIB_TABLE = g_new(int32_t, VIB_ENT * 2);\n ENV_CURVE = g_new(int32_t, 2 * EG_ENT + 1);\n \t/* make total level table */\n \tfor (t = 0;t < EG_ENT-1 ;t++){\n@@ -695,11 +679,11 @@ static int OPLOpenTable( void )\n \n static void OPLCloseTable( void )\n {\n- g_free(ENV_CURVE);\n-\tfree(TL_TABLE);\n-\tfree(SIN_TABLE);\n-\tfree(AMS_TABLE);\n-\tfree(VIB_TABLE);\n+ g_clear_pointer(&ENV_CURVE, g_free);\n+ g_clear_pointer(&TL_TABLE, g_free);\n+ g_clear_pointer(&SIN_TABLE, g_free);\n+ g_clear_pointer(&AMS_TABLE, g_free);\n+ g_clear_pointer(&VIB_TABLE, g_free);\n }\n \n /* CSM Key Control */\n@@ -1081,11 +1065,8 @@ FM_OPL *OPLCreate(int clock, int rate)\n \t/* allocate OPL state space */\n \tstate_size = sizeof(FM_OPL);\n \tstate_size += sizeof(OPL_CH)*max_ch;\n-\t/* allocate memory block */\n-\tptr = malloc(state_size);\n-\tif(ptr==NULL) return NULL;\n-\t/* clear */\n-\tmemset(ptr,0,state_size);\n+ /* allocate memory block and zero-initialize */\n+ ptr = g_malloc0(state_size);\n \tOPL = (FM_OPL *)ptr; ptr+=sizeof(FM_OPL);\n \tOPL->P_CH = (OPL_CH *)ptr; ptr+=sizeof(OPL_CH)*max_ch;\n \t/* set channel state pointer */\n@@ -1128,7 +1109,7 @@ void OPLDestroy(FM_OPL *OPL)\n \t}\n #endif\n \tOPL_UnLockTable();\n-\tfree(OPL);\n+ g_free(OPL);\n }\n \n /* ---------- Option handlers ---------- */\n", "prefixes": [ "v2" ] }