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

Re: [SUSPECTED SPAM][RESEND PATCH 1/2] tools/libxl: Mark pointer args of many functions constant


  • To: Anthony PERARD <anthony.perard@xxxxxxxxxx>, Elliott Mitchell <ehem+xen@xxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Wed, 28 Apr 2021 18:29:28 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aCz4otgMugYERjOoAomc5RppSGjfrhSdAplMcZqRPeo=; b=di1RtvUf3yc8IhSRXAT54gBDtLOx2c67djpG6SFMvCDTBXTA3TAF7FADYsfDdU5Bcb7TiBSNq9DsW2DI2ryNgt6Te+YHXZOsb0SxLN9ejhtLUv4sbmLSrUfXvveWn0bVA4dhVrROvioWiTDNI6nA/S4FLQ84IEncPiRmF20VlreNwR2xynCNP7mQIsdFsWTFPSDDzUFijRvhBp6ReqCT76eCAxtQH9s/K1p9nLdgxdEpUK5VUnIbhQOCjjujoEuf19S3H2SSO+EYTZL/Ks0BfvZYQatBVZo/gRRkeOiaDkIrXLvglqlCd3/0z9QEQDUr4QnYhPeRfCVCLk9WfmGybw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bl5cnXMdHdgDrCMDJJ1nCOk4JupLsLXGjry2jgcABjit721zKy4fxkPNB5zB46ofvaR5g0W8fi9VLUKOqV9GSnpExfatOFdQK/zY7T2BmBmHAw8BYmshJluf90qtLg4/a9rVFJWZHOc8FnYOAZFGQ3FeBR6oCFvKYpZOVIK0LH6QF9nB/2B0VadjA5TD7+o9SkAJJbSnmQ/BOEEEsCjCaR68A+X4nqFAHna1oAb0/sLwhy8c46Zg0iDOGW7AcSfso+rdTUgDkXfCnRHYv8g4U0eB6rNtGVtWIDQvPoRW2zSJhNQnacFNd6g33mjj3l5kmo0T7138J/g55bM4NJfjMQ==
  • Authentication-results: esa4.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Wed, 28 Apr 2021 17:30:04 +0000
  • Ironport-hdrordr: A9a23:JqDUuK5v4bMlGizT7APXwTuBI+orLtY04lQ7vn1ZYQBJc8Ceis CllOka0xixszoKRHQ8g7m7VZWoa3m0z/5IyKMWOqqvWxSjhXuwIOhZnO3f6hDDOwm7zO5S0q 98b7NzYeebMXFWhdv3iTPWL/8O29+CmZrHuc7/yDNXQRhue+Vc6W5Ce2SmO2lXYCUDOpYjDp qb4aN81l2dUFAadN6yCHVAf8WrnaypqLvcbRQLBwEq5WC15FvF1JfAHxeVxRsYWT9UqI1SlF TtqADl+r6l98iy1x607QTuxq5Lk9jswMYrPr3ptuEpLFzX6zqAVcBadJCp+Bs0p+yu71hCqq iynz4Qe/5dxlmUUmW8oR7G0xTt3jA0+xbZuCGlqEqmm+PVbnYXDNdAmJJ4f3LimjsdleA56o 1n9Sa4sIdaFhzJliiV3am5azha0nCajFBntMx7tQ0nbaIuLIV/gKZawWZuVLAHJy7+4JBPKp gSMOjsoMx4XHnfU2rUpQBUsaSRd0V2JDiqaG4YtPeY1jBH9UoJs3cw9YgkknAM+IlVceg+28 30dqBhlLR5RsQLd65KBOAYXcutCmDWKCi8Sl6vHQ==
  • Ironport-sdr: PuFU5jf7FqKEKT3lmqSNZ2DKcXPRIePr4BbqUtZhGTAQZpvA+EbJI1h0yDHpxP3/2f6PLnjzI1 WArNLCr1LNF9K6EMO2heaAUDatQG9e6TNG/1f1gHPxg5LHoNR1WpuFoWvEY/czjwVFwRbe+nPY 89OkEVvDFMlo38QK3GEXHqhxitUqBXLrqxMVPnCOtBpdIgNKCfmq381Nqo1HNxEg1ky3Di985Z 9uUcC7DysRWBuaB+LnyNHNU1FVw1iZWHuhqjWrxrVecybiAwEO0LN6Kq5/BJ0J+esbvVw6x+dw NEI=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 28/04/2021 18:12, Anthony PERARD wrote:
> On Fri, Dec 18, 2020 at 01:37:44PM -0800, Elliott Mitchell wrote:
>> --- a/tools/libs/light/libxl_internal.h
>> +++ b/tools/libs/light/libxl_internal.h
>> @@ -2073,9 +2073,9 @@ struct libxl__xen_console_reader {
>>  /* parse the string @s as a sequence of 6 colon separated bytes in to @mac 
>> */
>>  _hidden int libxl__parse_mac(const char *s, libxl_mac mac);
>>  /* compare mac address @a and @b. 0 if the same, -ve if a<b and +ve if a>b 
>> */
>> -_hidden int libxl__compare_macs(libxl_mac *a, libxl_mac *b);
>> +_hidden int libxl__compare_macs(const libxl_mac *a, const libxl_mac *b);
>>  /* return true if mac address is all zero (the default value) */
>> -_hidden int libxl__mac_is_default(libxl_mac *mac);
>> +_hidden int libxl__mac_is_default(const libxl_mac *mac);
> It turns out that older version of gcc complains about the const of
> libxl_mac:
>
>
>     libxl_nic.c: In function 'libxl_mac_to_device_nic':
>     libxl_nic.c:40:9: error: passing argument 1 of 'libxl__compare_macs' from 
> incompatible pointer type [-Werror]
>              if (!libxl__compare_macs(&mac_n, &nics[i].mac)) {
>              ^
>     In file included from libxl_nic.c:18:0:
>     libxl_internal.h:2076:13: note: expected 'const uint8_t (*)[6]' but 
> argument is of type 'uint8_t (*)[6]'
>      _hidden int libxl__compare_macs(const libxl_mac *a, const libxl_mac *b);
>                  ^
>     libxl_nic.c:40:9: error: passing argument 2 of 'libxl__compare_macs' from 
> incompatible pointer type [-Werror]
>              if (!libxl__compare_macs(&mac_n, &nics[i].mac)) {
>              ^
>     In file included from libxl_nic.c:18:0:
>     libxl_internal.h:2076:13: note: expected 'const uint8_t (*)[6]' but 
> argument is of type 'uint8_t (*)[6]'
>      _hidden int libxl__compare_macs(const libxl_mac *a, const libxl_mac *b);
>                  ^
>     libxl_nic.c: In function 'libxl__device_nic_setdefault':
>     libxl_nic.c:69:5: error: passing argument 1 of 'libxl__mac_is_default' 
> from incompatible pointer type [-Werror]
>          if (libxl__mac_is_default(&nic->mac)) {
>          ^
>     In file included from libxl_nic.c:18:0:
>     libxl_internal.h:2078:13: note: expected 'const uint8_t (*)[6]' but 
> argument is of type 'uint8_t (*)[6]'
>      _hidden int libxl__mac_is_default(const libxl_mac *mac);
>                  ^
>     cc1: all warnings being treated as errors

That's because the typedef for libxl_mac violates one of the well known
C beginner mistakes, by being a plain array behind the scenes.

A prototype of 'const libxl_mac mac[]' might fair better, except it
makes the code even more confusing to follow.

~Andrew




 


Rackspace

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