[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 2/6] libxl: change the type of libxl_cpuid_policy_list
- To: Roger Pau Monne <roger.pau@xxxxxxxxxx>
- From: Anthony PERARD <anthony.perard@xxxxxxxxxx>
- Date: Wed, 12 Jul 2023 17:02:03 +0100
- Authentication-results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
- Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Juergen Gross <jgross@xxxxxxxx>
- Delivery-date: Wed, 12 Jul 2023 16:02:23 +0000
- Ironport-data: A9a23:hcnXYK97j8pRaNy0zEdnDrUDlX6TJUtcMsCJ2f8bNWPcYEJGY0x3z 2sWUDuPPPiKMDGmf48iaISw90wDvsTXnIQwHVY9+3o8E34SpcT7XtnIdU2Y0wF+jCHgZBk+s 5hBMImowOQcFCK0SsKFa+C5xZVE/fjUAOG6UKicYXoZqTZMEE8JkQhkl/MynrlmiN24BxLlk d7pqojUNUTNNwRcawr40Ird7ks21BjOkGlA5AdmOqkR5AS2e0Q9V/rzG4ngdxMUfaEMdgKKb 76r5K20+Grf4yAsBruN+losWhRXKlJ6FVHmZkt+A8BOsDAbzsAB+v9T2M4nQVVWk120c+VZk 72hg3ASpTABZcUgkMxFO/VR/roX0aduoNcrKlDn2SCfItGvn9IBDJyCAWlvVbD09NqbDklf3 qQDImhXQiqH3eLm3ZbnGrk0hOUseZyD0IM34hmMzBncBPciB5vCX7/L9ZlT2zJYasJmRKiEI ZBDMHw2MUqGOkcUUrsUIMtWcOOAj3/jczpeuRSNqLA++WT7xw1tyrn9dtHSf7RmQO0MxxjA/ zuaoD+R7hcyC/Cc7hWE8luWofbumzr8Wp8cE4ed36s/6LGU7jNKU0BHPbehmtGph0j7V99BJ kg8/is1sbN05EGtVsP6XRCzvDiDpBF0c8VUO/037keK0KW8ywSWHG8fVRZadccr8sQxQFQC3 0eEhdrzCRRzsbeeTjSW8bL8kN+pEXFLdylYP3ZCFFZbpYC5++nfky4jUP5yO/auhIWvNQv0m TDasQxi1+VLj+8EgvDTEU/8v968mnTYZldrtlSOAj30slMRiJ2NPNLxtwWChRpUBMPAFwTa4 iBZ8ySLxLpWZaxhghBhVwnk8FuBw/+eeAPRjld0d3XK32T8oiXzFWy8DdwXGauIDirnUWWzC KMrkVkNjKK/xVPzBUONX6q/Ct4x0Y/rHsn/W/bfY7JmO8YhJVbfpHw2OxLKjwgBdXTAdolma f+mnTuEVy5GWcyLMhLrLwvi7VPb7n9nnj6CLXwK5x+mzaCfdBaopUQtaTOzghQCxPrc+m39q o8PX/ZmPj0DCIUSlAGLq99MRb3LRFBnba3LRzt/LLbZeVU7Rz1+VJc8A9oJIuRYokicrc+Ql lnVZ6OS4AOXaaHvQelSVk1eVQ==
- Ironport-hdrordr: A9a23:qfK6NqunqunagQy4Fx6Z+sHB7skDjNV00zEX/kB9WHVpm6yj+v xGUs566faUskd0ZJhEo7q90ca7Lk80maQa3WBzB8bGYOCFghrKEGgK1+KLrwEIcxeUygc379 YDT0ERMrzN5VgRt7eG3OG7eexQvOVuJsqT9JjjJ3QGd3AVV0l5hT0JbTpyiidNNXJ77ZxSLu v72uN34wCOVF4wdcqBCnwMT4H41qf2fMKPW29+O/Y/gjP+9Q+V1A==
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Tue, Jul 11, 2023 at 11:22:26AM +0200, Roger Pau Monne wrote:
> -void libxl_cpuid_dispose(libxl_cpuid_policy_list *p_cpuid_list)
> +void libxl_cpuid_dispose(libxl_cpuid_policy_list *pl)
> {
> - int i, j;
> - libxl_cpuid_policy_list cpuid_list = *p_cpuid_list;
> + libxl_cpuid_policy_list policy = *pl;
>
> - if (cpuid_list == NULL)
> + if (policy == NULL)
> return;
> - for (i = 0; cpuid_list[i].input[0] != XEN_CPUID_INPUT_UNUSED; i++) {
> - for (j = 0; j < 4; j++)
> - if (cpuid_list[i].policy[j] != NULL) {
> - free(cpuid_list[i].policy[j]);
> - cpuid_list[i].policy[j] = NULL;
> - }
> +
> + if (policy->cpuid) {
> + unsigned int i, j;
> + struct xc_xend_cpuid *cpuid_list = policy->cpuid;
> +
> + for (i = 0; cpuid_list[i].input[0] != XEN_CPUID_INPUT_UNUSED; i++) {
> + for (j = 0; j < 4; j++)
> + if (cpuid_list[i].policy[j] != NULL) {
> + free(cpuid_list[i].policy[j]);
> + cpuid_list[i].policy[j] = NULL;
> + }
This looks like a lot of work. We could just call
free(cpuid_list[i].policy[j]) and that's all, as cpuid_list will be gone
right after the loop.
Also, please add {} for the second "for ()" loop.
> + }
> + free(policy->cpuid);
> }
Beside some the coding style pointing out, the patch looks fine:
Reviewed-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
Thanks,
--
Anthony PERARD
|