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

[PATCH 4/6] arm/duart: make dt_uart_init() compile with -Wwrite-strings


  • To: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Mon, 20 Nov 2023 22:49:10 +0000
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Roberto Bagnara <roberto.bagnara@xxxxxxxxxxx>, Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
  • Delivery-date: Mon, 20 Nov 2023 22:49:31 +0000
  • Ironport-data: A9a23:3MPTDq+LoP2SHNuUIsiQDrUDX36TJUtcMsCJ2f8bNWPcYEJGY0x3m GJLWGuAbPiLN2qgf9wgboTg8U4D75aEm4NhTAJs+yA8E34SpcT7XtnIdU2Y0wF+jCHgZBk+s 5hBMImowOQcFCK0SsKFa+C5xZVE/fjVAOK6UKidYnwZqTZMEE8JkQhkl/MynrlmiN24BxLlk d7pqojUNUTNNwRcawr40Ird7ksz1BjOkGlA5AdnPKoT5AW2e0Q9V/rzG4ngdxMUfaEMdgKKb 76r5K20+Grf4yAsBruN+losWhRXKlJ6FVHmZkt+A8BOsDAbzsAB+v9T2M4nQVVWk120c+VZk 72hg3ASpTABZcUgkMxFO/VR/roX0aduoNcrKlDn2SCfItGvn9IBDJyCAWlvVbD09NqbDklq6 c0feCAvSiqdrKG02bOVFMQ23cQ8eZyD0IM34hmMzBncBPciB5vCX7/L9ZlT2zJYasJmRKiEI ZBDMHw2MUWGPEUn1lQ/UfrSmM+BgHXlfiIeg1WSvactuEDYzRBr0airO93QEjCPbZwPwRrD+ DmeogwVBDlEE4KvwgKO/0me3OzIvn71BaQUSqG3o6sCbFq7mTVIVUx+uUGAiem0jAuyVsxSL 2QQ+zEytu4i+UqzVN7/Uhak5nmesXY0QMFMGuc37AWMzKv84AuDAGUACDlbZ7QOttIyRDEs/ k+EmZXuHzMHmIOSTXWR57KFtwSYMCIeLXIBTSIcRA5D6N7myKk5gwjTVN9lHOiwh8fsBDDr6 zmQqW41gLB7pcsK3KWy+RbAmSChorDASwJz7QLSNkq/6Ql0fpKiIYah5l7S9/9oJpuWVVSHs z4PnM32xOYPBpaJnWqTTfkXHbeoz/yYPybRh1EpFJ4knwlB4Fb6I9oWumsnYh40Y4BbIVcFf XM/pyt1+K5UbGuISZVpSMGzEsUEk4W6TtT6A6W8gsV1XnRhSOOW1HgxPRbMjj63yRZErE0pB XuMnS+R4Zcm5UdPlmPeqx81i+ND+8zH7Tq7qWrH5xqmy6GCQ3WeVK0INlCDBshgs/vc/V2Iq YoGbpTUo/m6bAEYSnOPmWL0BQpSRUXX+Lis85AHHgJ9ClYO9J4d5w/5nup6Jt0Nc1V9nebU5 HCtMnK0O3Km7UAr3T6iMyg5AJu2BMYXkJ7OFXB0Vbpe8yR5MNnHAWZ2X8dfQITLA8Q6nKItE qFcI5rRahmNIxyekwkggVDGhNQKXHyWacimZkJJvBBXk0ZcejH0
  • Ironport-hdrordr: A9a23:rRuryKuMF6MG75yJeqwIG/u67skDTtV00zEX/kB9WHVpmszxra 6TdZMgpHnJYVcqKQkdcL+7WJVoLUmxyXcx2/h1AV7AZniAhILLFvAA0WKK+VSJcEeSygce79 YFT0EXMqyIMbEQt6fHCWeDfOrIuOP3kpyVuQ==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

GCC complains:

  drivers/char/arm-uart.c: In function 'dt_uart_init':
  drivers/char/arm-uart.c:81:17: error: assignment discards 'const' qualifier 
from pointer target type [-Werror=discarded-qualifiers]
     81 |         options = "";
        |                 ^

The problem is using the options string for both splitting opt_duart, and to
hold a token "" for no options.

Use two variables; one mutable one one const.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Stefano Stabellini <sstabellini@xxxxxxxxxx>
CC: Julien Grall <julien@xxxxxxx>
CC: Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
CC: Bertrand Marquis <bertrand.marquis@xxxxxxx>
CC: Michal Orzel <michal.orzel@xxxxxxx>
CC: Roberto Bagnara <roberto.bagnara@xxxxxxxxxxx>
CC: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
---
 xen/drivers/char/arm-uart.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/xen/drivers/char/arm-uart.c b/xen/drivers/char/arm-uart.c
index 8098a968c285..91f13a41368d 100644
--- a/xen/drivers/char/arm-uart.c
+++ b/xen/drivers/char/arm-uart.c
@@ -42,7 +42,8 @@ static void __init dt_uart_init(void)
     struct dt_device_node *dev;
     int ret;
     const char *devpath = opt_dtuart;
-    char *options;
+    const char *options;
+    char *split;
 
     if ( !console_has("dtuart") )
         return; /* Not for us */
@@ -74,9 +75,12 @@ static void __init dt_uart_init(void)
         return;
     }
 
-    options = strchr(opt_dtuart, ':');
-    if ( options != NULL )
-        *(options++) = '\0';
+    split = strchr(opt_dtuart, ':');
+    if ( split )
+    {
+        split[0] = '\0';
+        options = split + 1;
+    }
     else
         options = "";
 
-- 
2.30.2




 


Rackspace

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