You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "no1wudi (via GitHub)" <gi...@apache.org> on 2023/03/03 07:50:49 UTC

[GitHub] [nuttx] no1wudi opened a new pull request, #8707: arch/imx6: Fix a compilation error with UBSan

no1wudi opened a new pull request, #8707:
URL: https://github.com/apache/nuttx/pull/8707

   ## Summary
           Workaround for:
            chip/imx_gpio.c:545:7: error: case label does not reduce to an integer constant
            545 |       case GPIO_PERIPH:
                |       ^~~~
            
   ## Impact
   Minor
   ## Testing
   CI and QEMU
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] pkarashchenko commented on a diff in pull request #8707: arch/imx6: Fix a compilation error with UBSan

Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko commented on code in PR #8707:
URL: https://github.com/apache/nuttx/pull/8707#discussion_r1125607224


##########
arch/arm/src/imx6/imx_gpio.c:
##########
@@ -542,16 +544,25 @@ int imx_config_gpio(gpio_pinset_t pinset)
         }
         break;
 
-      case GPIO_PERIPH:
-        {
-          /* Configure the pin as a peripheral */
-
-          ret = imx_gpio_configperiph(pinset);
-        }
-        break;
-
       default:
-        ret = -EINVAL;
+
+        /* Workaround for:
+         * chip/imx_gpio.c:545:7: error: case label does not reduce to an
+         *   integer constant
+         *    545 |       case GPIO_PERIPH:
+         *        |       ^~~~
+         */
+
+        if (pinset == GPIO_PERIPH)

Review Comment:
   Should we fill a bug with the GCC bug tracking system?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] acassis commented on a diff in pull request #8707: arch/imx6: Fix a compilation error with UBSan

Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on code in PR #8707:
URL: https://github.com/apache/nuttx/pull/8707#discussion_r1125562624


##########
arch/arm/src/imx6/imx_gpio.c:
##########
@@ -542,16 +544,25 @@ int imx_config_gpio(gpio_pinset_t pinset)
         }
         break;
 
-      case GPIO_PERIPH:
-        {
-          /* Configure the pin as a peripheral */
-
-          ret = imx_gpio_configperiph(pinset);
-        }
-        break;
-
       default:
-        ret = -EINVAL;
+
+        /* Workaround for:
+         * chip/imx_gpio.c:545:7: error: case label does not reduce to an
+         *   integer constant
+         *    545 |       case GPIO_PERIPH:
+         *        |       ^~~~
+         */
+
+        if (pinset == GPIO_PERIPH)

Review Comment:
   Normally this message is displayed when someone use a variable instead of a constant: https://www.includehelp.com/c-programs/case-label-does-not-reduce-to-an-integer-constant-error-in-c.aspx
   
   This error shouldn't happen when using GPIO_PERIPH.
   
   @no1wudi did you try replacing "case GPIO_PERIPH" with "case  (2 << 30)" just to confirm that the issue could be related to the signal bit?
   
   Hmm, interesting test:
   
   ```
     const int c = 1;
     swtich ...
       case c:
         printf("case c\n"); break;
   ```
   
   clang accepts it, but gcc (11.3.0) raises an error:
   
   ```
   testcase.c:12:9: error: case label does not reduce to an integer constant
      12 |         case c:     //no compile error for clang
         |         ^~~~
   ```



##########
arch/arm/src/imx6/imx_gpio.c:
##########
@@ -542,16 +544,25 @@ int imx_config_gpio(gpio_pinset_t pinset)
         }
         break;
 
-      case GPIO_PERIPH:
-        {
-          /* Configure the pin as a peripheral */
-
-          ret = imx_gpio_configperiph(pinset);
-        }
-        break;
-
       default:
-        ret = -EINVAL;
+
+        /* Workaround for:
+         * chip/imx_gpio.c:545:7: error: case label does not reduce to an
+         *   integer constant
+         *    545 |       case GPIO_PERIPH:
+         *        |       ^~~~
+         */
+
+        if (pinset == GPIO_PERIPH)

Review Comment:
   Normally this message is displayed when someone use a variable instead of a constant: https://www.includehelp.com/c-programs/case-label-does-not-reduce-to-an-integer-constant-error-in-c.aspx
   
   This error shouldn't happen when using GPIO_PERIPH.
   
   @no1wudi did you try replacing "case GPIO_PERIPH" with "case  (2 << 30)" just to confirm that the issue could be related to the signal bit?
   
   Hmm, interesting test:
   
   ```
     const int c = 1;
     switch ...
       case c:
         printf("case c\n"); break;
   ```
   
   clang accepts it, but gcc (11.3.0) raises an error:
   
   ```
   testcase.c:12:9: error: case label does not reduce to an integer constant
      12 |         case c:     //no compile error for clang
         |         ^~~~
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] no1wudi commented on a diff in pull request #8707: arch/imx6: Fix a compilation error with UBSan

Posted by "no1wudi (via GitHub)" <gi...@apache.org>.
no1wudi commented on code in PR #8707:
URL: https://github.com/apache/nuttx/pull/8707#discussion_r1125596292


##########
arch/arm/src/imx6/imx_gpio.c:
##########
@@ -542,16 +544,25 @@ int imx_config_gpio(gpio_pinset_t pinset)
         }
         break;
 
-      case GPIO_PERIPH:
-        {
-          /* Configure the pin as a peripheral */
-
-          ret = imx_gpio_configperiph(pinset);
-        }
-        break;
-
       default:
-        ret = -EINVAL;
+
+        /* Workaround for:
+         * chip/imx_gpio.c:545:7: error: case label does not reduce to an
+         *   integer constant
+         *    545 |       case GPIO_PERIPH:
+         *        |       ^~~~
+         */
+
+        if (pinset == GPIO_PERIPH)

Review Comment:
   It works,  so should we change the definition of this macro?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] pkarashchenko commented on a diff in pull request #8707: arch/imx6: Fix a compilation error with UBSan

Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko commented on code in PR #8707:
URL: https://github.com/apache/nuttx/pull/8707#discussion_r1125607449


##########
arch/arm/src/imx6/imx_gpio.c:
##########
@@ -542,16 +544,25 @@ int imx_config_gpio(gpio_pinset_t pinset)
         }
         break;
 
-      case GPIO_PERIPH:
-        {
-          /* Configure the pin as a peripheral */
-
-          ret = imx_gpio_configperiph(pinset);
-        }
-        break;
-
       default:
-        ret = -EINVAL;
+
+        /* Workaround for:
+         * chip/imx_gpio.c:545:7: error: case label does not reduce to an
+         *   integer constant
+         *    545 |       case GPIO_PERIPH:
+         *        |       ^~~~
+         */
+
+        if (pinset == GPIO_PERIPH)

Review Comment:
   I believe that it is not a single place in the code that will have such an issue. Also a question will `(2u << 30)` also generate an issue, or is it only a limitation of int?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] no1wudi commented on a diff in pull request #8707: arch/imx6: Fix a compilation error with UBSan

Posted by "no1wudi (via GitHub)" <gi...@apache.org>.
no1wudi commented on code in PR #8707:
URL: https://github.com/apache/nuttx/pull/8707#discussion_r1124211139


##########
arch/arm/src/imx6/imx_gpio.c:
##########
@@ -542,16 +544,25 @@ int imx_config_gpio(gpio_pinset_t pinset)
         }
         break;
 
-      case GPIO_PERIPH:
-        {
-          /* Configure the pin as a peripheral */
-
-          ret = imx_gpio_configperiph(pinset);
-        }
-        break;
-
       default:
-        ret = -EINVAL;
+
+        /* Workaround for:
+         * chip/imx_gpio.c:545:7: error: case label does not reduce to an
+         *   integer constant
+         *    545 |       case GPIO_PERIPH:
+         *        |       ^~~~
+         */
+
+        if (pinset == GPIO_PERIPH)

Review Comment:
   Yes, `GPIO_PERIPH` is (2 << 30)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] pkarashchenko commented on a diff in pull request #8707: arch/imx6: Fix a compilation error with UBSan

Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko commented on code in PR #8707:
URL: https://github.com/apache/nuttx/pull/8707#discussion_r1125441003


##########
arch/arm/src/imx6/imx_gpio.c:
##########
@@ -542,16 +544,25 @@ int imx_config_gpio(gpio_pinset_t pinset)
         }
         break;
 
-      case GPIO_PERIPH:
-        {
-          /* Configure the pin as a peripheral */
-
-          ret = imx_gpio_configperiph(pinset);
-        }
-        break;
-
       default:
-        ret = -EINVAL;
+
+        /* Workaround for:
+         * chip/imx_gpio.c:545:7: error: case label does not reduce to an
+         *   integer constant
+         *    545 |       case GPIO_PERIPH:
+         *        |       ^~~~
+         */
+
+        if (pinset == GPIO_PERIPH)

Review Comment:
   I will try it out. The first glance seems like this is because only bit 31 is set, but I'm not aware of such limitations in C.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] pkarashchenko merged pull request #8707: arch/imx6: Fix a compilation error with UBSan

Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko merged PR #8707:
URL: https://github.com/apache/nuttx/pull/8707


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] pkarashchenko commented on a diff in pull request #8707: arch/imx6: Fix a compilation error with UBSan

Posted by "pkarashchenko (via GitHub)" <gi...@apache.org>.
pkarashchenko commented on code in PR #8707:
URL: https://github.com/apache/nuttx/pull/8707#discussion_r1124380272


##########
arch/arm/src/imx6/imx_gpio.c:
##########
@@ -542,16 +544,25 @@ int imx_config_gpio(gpio_pinset_t pinset)
         }
         break;
 
-      case GPIO_PERIPH:
-        {
-          /* Configure the pin as a peripheral */
-
-          ret = imx_gpio_configperiph(pinset);
-        }
-        break;
-
       default:
-        ret = -EINVAL;
+
+        /* Workaround for:
+         * chip/imx_gpio.c:545:7: error: case label does not reduce to an
+         *   integer constant
+         *    545 |       case GPIO_PERIPH:
+         *        |       ^~~~
+         */
+
+        if (pinset == GPIO_PERIPH)

Review Comment:
   this change is wired. How it can be reproduced?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] no1wudi commented on a diff in pull request #8707: arch/imx6: Fix a compilation error with UBSan

Posted by "no1wudi (via GitHub)" <gi...@apache.org>.
no1wudi commented on code in PR #8707:
URL: https://github.com/apache/nuttx/pull/8707#discussion_r1124444436


##########
arch/arm/src/imx6/imx_gpio.c:
##########
@@ -542,16 +544,25 @@ int imx_config_gpio(gpio_pinset_t pinset)
         }
         break;
 
-      case GPIO_PERIPH:
-        {
-          /* Configure the pin as a peripheral */
-
-          ret = imx_gpio_configperiph(pinset);
-        }
-        break;
-
       default:
-        ret = -EINVAL;
+
+        /* Workaround for:
+         * chip/imx_gpio.c:545:7: error: case label does not reduce to an
+         *   integer constant
+         *    545 |       case GPIO_PERIPH:
+         *        |       ^~~~
+         */
+
+        if (pinset == GPIO_PERIPH)

Review Comment:
   Use sabre-6quad:nsh, and enable CONFIG_MM_UBSAN and CONFIG_MM_UBSAN_ALL



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #8707: arch/imx6: Fix a compilation error with UBSan

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #8707:
URL: https://github.com/apache/nuttx/pull/8707#discussion_r1125608962


##########
arch/arm/src/imx6/imx_gpio.c:
##########
@@ -542,16 +544,25 @@ int imx_config_gpio(gpio_pinset_t pinset)
         }
         break;
 
-      case GPIO_PERIPH:
-        {
-          /* Configure the pin as a peripheral */
-
-          ret = imx_gpio_configperiph(pinset);
-        }
-        break;
-
       default:
-        ret = -EINVAL;
+
+        /* Workaround for:
+         * chip/imx_gpio.c:545:7: error: case label does not reduce to an
+         *   integer constant
+         *    545 |       case GPIO_PERIPH:
+         *        |       ^~~~
+         */
+
+        if (pinset == GPIO_PERIPH)

Review Comment:
   > Should we fill a bug with the GCC bug tracking system?
   
   Yes, I think so.
   
   > I believe that it is not a single place in the code that will have such an issue. Also a question will `(2u << 30)` also generate an issue, or is it only a limitation of int?
   
   it's a problem of UBSan, I think. The origin code work well without UBSan enable.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #8707: arch/imx6: Fix a compilation error with UBSan

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #8707:
URL: https://github.com/apache/nuttx/pull/8707#discussion_r1125601504


##########
arch/arm/src/imx6/imx_gpio.c:
##########
@@ -542,16 +544,25 @@ int imx_config_gpio(gpio_pinset_t pinset)
         }
         break;
 
-      case GPIO_PERIPH:
-        {
-          /* Configure the pin as a peripheral */
-
-          ret = imx_gpio_configperiph(pinset);
-        }
-        break;
-
       default:
-        ret = -EINVAL;
+
+        /* Workaround for:
+         * chip/imx_gpio.c:545:7: error: case label does not reduce to an
+         *   integer constant
+         *    545 |       case GPIO_PERIPH:
+         *        |       ^~~~
+         */
+
+        if (pinset == GPIO_PERIPH)

Review Comment:
   at least, it's better than the current change.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #8707: arch/imx6: Fix a compilation error with UBSan

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #8707:
URL: https://github.com/apache/nuttx/pull/8707#discussion_r1125587663


##########
arch/arm/src/imx6/imx_gpio.c:
##########
@@ -542,16 +544,25 @@ int imx_config_gpio(gpio_pinset_t pinset)
         }
         break;
 
-      case GPIO_PERIPH:
-        {
-          /* Configure the pin as a peripheral */
-
-          ret = imx_gpio_configperiph(pinset);
-        }
-        break;
-
       default:
-        ret = -EINVAL;
+
+        /* Workaround for:
+         * chip/imx_gpio.c:545:7: error: case label does not reduce to an
+         *   integer constant
+         *    545 |       case GPIO_PERIPH:
+         *        |       ^~~~
+         */
+
+        if (pinset == GPIO_PERIPH)

Review Comment:
   so it's gcc bug when UBSan is enabled?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] no1wudi commented on a diff in pull request #8707: arch/imx6: Fix a compilation error with UBSan

Posted by "no1wudi (via GitHub)" <gi...@apache.org>.
no1wudi commented on code in PR #8707:
URL: https://github.com/apache/nuttx/pull/8707#discussion_r1125593495


##########
arch/arm/src/imx6/imx_gpio.c:
##########
@@ -542,16 +544,25 @@ int imx_config_gpio(gpio_pinset_t pinset)
         }
         break;
 
-      case GPIO_PERIPH:
-        {
-          /* Configure the pin as a peripheral */
-
-          ret = imx_gpio_configperiph(pinset);
-        }
-        break;
-
       default:
-        ret = -EINVAL;
+
+        /* Workaround for:
+         * chip/imx_gpio.c:545:7: error: case label does not reduce to an
+         *   integer constant
+         *    545 |       case GPIO_PERIPH:
+         *        |       ^~~~
+         */
+
+        if (pinset == GPIO_PERIPH)

Review Comment:
   Yes, it should be a bug or
    limit with ubsan enabled.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] no1wudi commented on a diff in pull request #8707: arch/imx6: Fix a compilation error with UBSan

Posted by "no1wudi (via GitHub)" <gi...@apache.org>.
no1wudi commented on code in PR #8707:
URL: https://github.com/apache/nuttx/pull/8707#discussion_r1124444436


##########
arch/arm/src/imx6/imx_gpio.c:
##########
@@ -542,16 +544,25 @@ int imx_config_gpio(gpio_pinset_t pinset)
         }
         break;
 
-      case GPIO_PERIPH:
-        {
-          /* Configure the pin as a peripheral */
-
-          ret = imx_gpio_configperiph(pinset);
-        }
-        break;
-
       default:
-        ret = -EINVAL;
+
+        /* Workaround for:
+         * chip/imx_gpio.c:545:7: error: case label does not reduce to an
+         *   integer constant
+         *    545 |       case GPIO_PERIPH:
+         *        |       ^~~~
+         */
+
+        if (pinset == GPIO_PERIPH)

Review Comment:
   Use sabre-6quad:nsh, enable CONFIG_MM_UBSAN and CONFIG_MM_UBSAN_ALL



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] acassis commented on a diff in pull request #8707: arch/imx6: Fix a compilation error with UBSan

Posted by "acassis (via GitHub)" <gi...@apache.org>.
acassis commented on code in PR #8707:
URL: https://github.com/apache/nuttx/pull/8707#discussion_r1125562624


##########
arch/arm/src/imx6/imx_gpio.c:
##########
@@ -542,16 +544,25 @@ int imx_config_gpio(gpio_pinset_t pinset)
         }
         break;
 
-      case GPIO_PERIPH:
-        {
-          /* Configure the pin as a peripheral */
-
-          ret = imx_gpio_configperiph(pinset);
-        }
-        break;
-
       default:
-        ret = -EINVAL;
+
+        /* Workaround for:
+         * chip/imx_gpio.c:545:7: error: case label does not reduce to an
+         *   integer constant
+         *    545 |       case GPIO_PERIPH:
+         *        |       ^~~~
+         */
+
+        if (pinset == GPIO_PERIPH)

Review Comment:
   Normally this message is displayed when someone use a variable instead of a constant: https://www.includehelp.com/c-programs/case-label-does-not-reduce-to-an-integer-constant-error-in-c.aspx
   
   This error shouldn't happen when using GPIO_PERIPH.
   
   @no1wudi did you try replacing "case GPIO_PERIPH" with "case  (2 << 30)" just to confirm that the issue could be related to the signal bit?
   
   Hmm, interesting test:
   
   ```
     const int c = 1;
   
     case c:
       printf("case c\n"); break;
   ```
   
   clang accepts it, but gcc (11.3.0) raises an error:
   
   ```
   testcase.c:12:9: error: case label does not reduce to an integer constant
      12 |         case c:     //no compile error for clang
         |         ^~~~
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #8707: arch/imx6: Fix a compilation error with UBSan

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #8707:
URL: https://github.com/apache/nuttx/pull/8707#discussion_r1124205985


##########
arch/arm/src/imx6/imx_gpio.c:
##########
@@ -542,16 +544,25 @@ int imx_config_gpio(gpio_pinset_t pinset)
         }
         break;
 
-      case GPIO_PERIPH:
-        {
-          /* Configure the pin as a peripheral */
-
-          ret = imx_gpio_configperiph(pinset);
-        }
-        break;
-
       default:
-        ret = -EINVAL;
+
+        /* Workaround for:
+         * chip/imx_gpio.c:545:7: error: case label does not reduce to an
+         *   integer constant
+         *    545 |       case GPIO_PERIPH:
+         *        |       ^~~~
+         */
+
+        if (pinset == GPIO_PERIPH)

Review Comment:
   but GPIO_PERIPH is a const macro?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] xiaoxiang781216 commented on a diff in pull request #8707: arch/imx6: Fix a compilation error with UBSan

Posted by "xiaoxiang781216 (via GitHub)" <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #8707:
URL: https://github.com/apache/nuttx/pull/8707#discussion_r1125593810


##########
arch/arm/src/imx6/imx_gpio.c:
##########
@@ -542,16 +544,25 @@ int imx_config_gpio(gpio_pinset_t pinset)
         }
         break;
 
-      case GPIO_PERIPH:
-        {
-          /* Configure the pin as a peripheral */
-
-          ret = imx_gpio_configperiph(pinset);
-        }
-        break;
-
       default:
-        ret = -EINVAL;
+
+        /* Workaround for:
+         * chip/imx_gpio.c:545:7: error: case label does not reduce to an
+         *   integer constant
+         *    545 |       case GPIO_PERIPH:
+         *        |       ^~~~
+         */
+
+        if (pinset == GPIO_PERIPH)

Review Comment:
   how about we ue 0x80000000?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] no1wudi commented on a diff in pull request #8707: arch/imx6: Fix a compilation error with UBSan

Posted by "no1wudi (via GitHub)" <gi...@apache.org>.
no1wudi commented on code in PR #8707:
URL: https://github.com/apache/nuttx/pull/8707#discussion_r1125579011


##########
arch/arm/src/imx6/imx_gpio.c:
##########
@@ -542,16 +544,25 @@ int imx_config_gpio(gpio_pinset_t pinset)
         }
         break;
 
-      case GPIO_PERIPH:
-        {
-          /* Configure the pin as a peripheral */
-
-          ret = imx_gpio_configperiph(pinset);
-        }
-        break;
-
       default:
-        ret = -EINVAL;
+
+        /* Workaround for:
+         * chip/imx_gpio.c:545:7: error: case label does not reduce to an
+         *   integer constant
+         *    545 |       case GPIO_PERIPH:
+         *        |       ^~~~
+         */
+
+        if (pinset == GPIO_PERIPH)

Review Comment:
   @acassis Yes, i
    have tried (2<<30), and this issue also exists in riscv gcc.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [nuttx] no1wudi commented on a diff in pull request #8707: arch/imx6: Fix a compilation error with UBSan

Posted by "no1wudi (via GitHub)" <gi...@apache.org>.
no1wudi commented on code in PR #8707:
URL: https://github.com/apache/nuttx/pull/8707#discussion_r1125608713


##########
arch/arm/src/imx6/imx_gpio.c:
##########
@@ -542,16 +544,25 @@ int imx_config_gpio(gpio_pinset_t pinset)
         }
         break;
 
-      case GPIO_PERIPH:
-        {
-          /* Configure the pin as a peripheral */
-
-          ret = imx_gpio_configperiph(pinset);
-        }
-        break;
-
       default:
-        ret = -EINVAL;
+
+        /* Workaround for:
+         * chip/imx_gpio.c:545:7: error: case label does not reduce to an
+         *   integer constant
+         *    545 |       case GPIO_PERIPH:
+         *        |       ^~~~
+         */
+
+        if (pinset == GPIO_PERIPH)

Review Comment:
   (2u << 30)will not report this issue, changed to unsigned definitions now.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org