[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 4/4] dt-overlay: Support target-path being root node


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • From: Michal Orzel <michal.orzel@xxxxxxx>
  • Date: Mon, 23 Sep 2024 12:46:25 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3Kd44UCtEgezqrfF3C7O/Fj9QkNgjdTU3MD7b7VcG3E=; b=UdAEgGvdRibJmbCoHStJVvgkJA/spvhFl7s7tZUtm3eDf40HB1AqJMm7+4MJISHKFThIstFnXNueQEXbptwFdGAF5Diu0I+f9SIWbU5WSkCWf5QlfBqLAjt/TlaPXxUZCkxDBTGqbD+PkN3rrfmfnAR48h0vTDIUqJEi6k88CeNywv7MKpCMgR9broI/khAGDNxZBuOaEaeeVy64faKYGFTY958F3AZZcbSHrgRXaun/XT4nkgj3T82yVRHbTDio4LMQuud5EX7Mjn1p5eeykHQc7PCp1E/yuj1dnTgs9LLeS/spt1ZTdz/w2VqyrKbtjxXEywfhITV3p3zJv7mTQw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=T84wAyDE50qqW//P2WckfZZBEkesPdXw5I88kLW4SHJgMzTAX07NTSqqwJzkFywwN+37onb2s/qz591/n84t9vwRYbFoaL7l05FdJG3XYJSUiC/Tml2i4GYeNbChlzs2j/M3ga8oR30Vbdq+7wEeAdP2w6x46mUGptcQdkE1ddw1vBEZj0bn2nPkhrdjxvC7iJKCjYO/x6vV/N19DL67Gq/nuUce043BBdwZMUzYiKyzRL6dBirrUUy0EDpqT/h3L+2zhRRozVlzN4lFUwG94zYQre6tKIesbtwA3PnsNv8bvsITsTp67Fn20P4ytuszWoNesRs/iy+vF+od0HMVlg==
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>
  • Delivery-date: Mon, 23 Sep 2024 10:46:39 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>


On 20/09/2024 05:54, Stefano Stabellini wrote:
> 
> 
> On Thu, 19 Sep 2024, Michal Orzel wrote:
>> Even though in most cases device nodes are not present directly under
>> the root node, it's a perfectly valid configuration (e.g. Qemu virt
>> machine dtb). At the moment, we don't handle this scenario which leads
>> to unconditional addition of extra leading '/' in the node full path.
>> This makes the attempt to add such device overlay to fail.
>>
>> Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
>> ---
>>  xen/common/dt-overlay.c | 16 +++++++++++-----
>>  1 file changed, 11 insertions(+), 5 deletions(-)
>>
>> diff --git a/xen/common/dt-overlay.c b/xen/common/dt-overlay.c
>> index d18bd12bd38d..63b28889de90 100644
>> --- a/xen/common/dt-overlay.c
>> +++ b/xen/common/dt-overlay.c
>> @@ -325,6 +325,7 @@ static int overlay_get_nodes_info(const void *fdto, char 
>> **nodes_full_path)
>>              int node_name_len;
>>              unsigned int target_path_len = strlen(target_path);
>>              unsigned int node_full_name_len;
>> +            unsigned int extra_len;
>>
>>              node_name = fdt_get_name(fdto, subnode, &node_name_len);
>>
>> @@ -332,10 +333,13 @@ static int overlay_get_nodes_info(const void *fdto, 
>> char **nodes_full_path)
>>                  return node_name_len;
>>
>>              /*
>> -             * Magic number 2 is for adding '/' and '\0'. This is done to 
>> keep
>> -             * the node_full_path in the correct full node name format.
>> +             * Extra length is for adding '/' and '\0' unless the target 
>> path is
>> +             * root in which case we don't add the '/' at the beginning. 
>> This is
>> +             * done to keep the node_full_path in the correct full node name
>> +             * format.
>>               */
>> -            node_full_name_len = target_path_len + node_name_len + 2;
>> +            extra_len = (target_path_len > 1) + 1;
> 
> I'd prefer to avoid the implicit bool to int conversion. I think it is
> mandated by MISRA R10.1, we have a bool exception but I don't think it
> would cover this type of usage. For instance:
> 
> extra_len = ((target_path_len > 1) ? 1 : 0)  + 1;
> 
> or
> 
> extra_len = (target_path_len > 1) ? 2 : 1;
Ok, will do this version.

~Michal



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.