From patchwork Mon Oct 28 18:22:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleksandr Grytsov X-Patchwork-Id: 11216269 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1FAA9913 for ; Mon, 28 Oct 2019 18:23:59 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EE0DE214B2 for ; Mon, 28 Oct 2019 18:23:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gm9/ZNAn" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EE0DE214B2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iP9f1-0000ln-B4; Mon, 28 Oct 2019 18:22:35 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iP9ez-0000lZ-Lf for xen-devel@lists.xenproject.org; Mon, 28 Oct 2019 18:22:33 +0000 X-Inumbo-ID: e5e30b78-f9af-11e9-beca-bc764e2007e4 Received: from mail-lf1-x143.google.com (unknown [2a00:1450:4864:20::143]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id e5e30b78-f9af-11e9-beca-bc764e2007e4; Mon, 28 Oct 2019 18:22:28 +0000 (UTC) Received: by mail-lf1-x143.google.com with SMTP id f5so8569541lfp.1 for ; Mon, 28 Oct 2019 11:22:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=x6gcVv6ZDlEFCzeVFBOyHJn95rgYFyAe3I5FPXjfjEA=; b=gm9/ZNAnpUx4H9Rr2W+ONu8mpYfWjjCE+5YtaFBb/PDpUTno1M1Se96QcGazv54bE4 JdYD1ZmXnAtYyiJf3juMo/s5Wbp0BOijruWqpDt3Cvm9YSUYZLTnM1ljfWQRBV76EFs/ fAjNexz2V3ZoNpXyKaHY08cMHjUN3OCV38sUfPsuWn1kcvLytIVwCHr+lAAxZjiQQzGp uL1Wuz4WTW2RYZuZrE4kQmttgs4EBY9LPSEDCqRFgwnxuk8N9IqqwuCdajk0LHY9mQXo xd8RDyrEpGOTZmIlsUDN2PP/OF3syX3nlHjRsMglKL5WD+d72nzuVWYEgUMCNZ85OgfH iYgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=x6gcVv6ZDlEFCzeVFBOyHJn95rgYFyAe3I5FPXjfjEA=; b=qLS0aboEyKQ6PeubNtW2IXvDXhodJAG6RrR4W8iBLj+Ciegi2viaUqk5pWA2viFR7F s1SdBh3dQ/PM5KGYAAGjbJ0UNa9bqvHIJ5F3QundBYHHj3hF/nfmQnR8OCDAfU5MTgFJ ywUy3Gp+fdyKt8EiscJRWzccyldq8mIULkFBI/T/fgfBWnMPqF7KbUtAxotQf6WDx8Yh C1lUP9/CTkcd3l5WZsTMJLz9J/63gs+DKH+jqPzwN/xg+W5qFxiI4q8InNhBP2NqtXiZ EgiesdTnsC4T/PbQOEtJJAhnxv3sY8+TWouSIlNfB0EpDpzyqUejPhejZS96sIgABPWF 7xgg== X-Gm-Message-State: APjAAAVYW27Ln2OADx2bCyO9W29LzMzEd4oV6+YCyFpmLY2NeaCs6j6L x9TJu1Yj6cvLZ/zC0qiWlp01lBHXsiEGuw== X-Google-Smtp-Source: APXvYqy9PMJSmzxNlHHRH056OzSqJbgI3Jr5398D0qOOjW0KtKJbSv8w7pcGWuZYBap7tdRJrI/FQA== X-Received: by 2002:ac2:43b6:: with SMTP id t22mr5557400lfl.126.1572286947621; Mon, 28 Oct 2019 11:22:27 -0700 (PDT) Received: from al1-pc.kyiv.epam.com (ll-74.141.223.85.sovam.net.ua. [85.223.141.74]) by smtp.gmail.com with ESMTPSA id p86sm7474522lja.100.2019.10.28.11.22.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 11:22:27 -0700 (PDT) From: Oleksandr Grytsov To: xen-devel@lists.xenproject.org Date: Mon, 28 Oct 2019 20:22:16 +0200 Message-Id: <20191028182216.3882-2-al1img@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191028182216.3882-1-al1img@gmail.com> References: <20191028182216.3882-1-al1img@gmail.com> Subject: [Xen-devel] [PATCH v1 1/1] libxl/gentypes: add range init to array elements in json parsing X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: anthony.perard@citrix.com, Oleksandr Grytsov , julien.grall@arm.com, ian.jackson@eu.citrix.com, wl@xen.org MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" From: Oleksandr Grytsov Add initialization of array elements in parse json function. Currently, array elements are initialized with calloc. Which means initialize all element fields with zero values. If entries are missed in json for such fields, it will be equal to zero instead of default values. The fix is to add range init function before parsing array element for structures which have defined range init function. Signed-off-by: Oleksandr Grytsov --- tools/libxl/gentypes.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/libxl/gentypes.py b/tools/libxl/gentypes.py index 6417c9dd8c..4ff5d8a2d0 100644 --- a/tools/libxl/gentypes.py +++ b/tools/libxl/gentypes.py @@ -456,6 +456,8 @@ def libxl_C_type_parse_json(ty, w, v, indent = " ", parent = None, discrimina s += " goto out;\n" s += " }\n" s += " for (i=0; (t=libxl__json_array_get(x,i)); i++) {\n" + if ty.elem_type.init_fn is not None and ty.elem_type.autogenerate_init_fn: + s += indent + " "+"%s_init(&%s[i]);\n" % (ty.elem_type.typename, v) s += libxl_C_type_parse_json(ty.elem_type, "t", v+"[i]", indent + " ", parent) s += " }\n"