You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/11/19 15:57:46 UTC

[GitHub] [incubator-nuttx-apps] xiaoxiang781216 opened a new pull request, #1426: Fix clang compiler warning

xiaoxiang781216 opened a new pull request, #1426:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1426

   ## Summary
   Found by https://github.com/apache/incubator-nuttx/pull/7391
   
   ## Impact
   Minor
   
   ## Testing
   Pass CI
   


-- 
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] [incubator-nuttx-apps] xiaoxiang781216 commented on a diff in pull request #1426: Fix clang compiler warning

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #1426:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1426#discussion_r1027120201


##########
examples/dac/dac_main.c:
##########
@@ -110,15 +110,15 @@ static void print_cmds(FAR const char *header,
                        size_t ncmds,
                        FAR const char *trailer)
 {
-  printf(header);
+  printf("%s", header);

Review Comment:
   Here:
   ```
   Error: format string is not a string literal (potentially insecure)
   ```
   In general is dangerous to printf(str) and the content of str can't be determined in compile time since str may contain % and trigger printf do some bad action.



-- 
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] [incubator-nuttx-apps] pkarashchenko commented on a diff in pull request #1426: Fix clang compiler warning

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #1426:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1426#discussion_r1027121781


##########
examples/dac/dac_main.c:
##########
@@ -110,15 +110,15 @@ static void print_cmds(FAR const char *header,
                        size_t ncmds,
                        FAR const char *trailer)
 {
-  printf(header);
+  printf("%s", header);

Review Comment:
   The printf is used below, so let's go with the current change. Otherwise I would recommend to use puts



-- 
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] [incubator-nuttx-apps] pkarashchenko merged pull request #1426: Fix clang compiler warning

Posted by GitBox <gi...@apache.org>.
pkarashchenko merged PR #1426:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1426


-- 
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] [incubator-nuttx-apps] pkarashchenko commented on a diff in pull request #1426: Fix clang compiler warning

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on code in PR #1426:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1426#discussion_r1027109606


##########
examples/dac/dac_main.c:
##########
@@ -110,15 +110,15 @@ static void print_cmds(FAR const char *header,
                        size_t ncmds,
                        FAR const char *trailer)
 {
-  printf(header);
+  printf("%s", header);

Review Comment:
   Sorry, but what was the warning here? The `header` seems to be `const char*`



##########
examples/foc/foc_fixed16_thr.c:
##########
@@ -185,9 +185,10 @@ int foc_fixed16_thr(FAR struct foc_ctrl_env_s *envp)
   struct foc_mq_s         handle;
   struct foc_motor_b16_s  motor;
   struct foc_device_s     dev;
-  int                     time      = 0;
-  int                     ret       = OK;
+  int                     time = 0;

Review Comment:
   Maybe
   ```suggestion
   #ifdef FOC_STATE_PRINT_PRE
     int                     time = 0;
   #endif
   ```
   instead?



##########
examples/dac/dac_main.c:
##########
@@ -110,15 +110,15 @@ static void print_cmds(FAR const char *header,
                        size_t ncmds,
                        FAR const char *trailer)
 {
-  printf(header);
+  printf("%s", header);
   while (ncmds--)
     {
       printf("  %s %s %c", cmds->name, cmds->args,
                            (ncmds > 0) ? '\n' : ' ');
       cmds++;
     }
 
-  printf(trailer);
+  printf("%s", trailer);

Review Comment:
   ditto



##########
examples/foc/foc_float_thr.c:
##########
@@ -186,9 +186,10 @@ int foc_float_thr(FAR struct foc_ctrl_env_s *envp)
   struct foc_mq_s         handle;
   struct foc_motor_f32_s  motor;
   struct foc_device_s     dev;
-  int                     time      = 0;
-  int                     ret       = OK;
+  int                     time = 0;

Review Comment:
   ditto



-- 
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] [incubator-nuttx-apps] xiaoxiang781216 commented on a diff in pull request #1426: Fix clang compiler warning

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #1426:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1426#discussion_r1027120483


##########
examples/foc/foc_fixed16_thr.c:
##########
@@ -185,9 +185,10 @@ int foc_fixed16_thr(FAR struct foc_ctrl_env_s *envp)
   struct foc_mq_s         handle;
   struct foc_motor_b16_s  motor;
   struct foc_device_s     dev;
-  int                     time      = 0;
-  int                     ret       = OK;
+  int                     time = 0;

Review Comment:
   Can't since time is also used in other places which isn't guarded by FOC_STATE_PRINT_PRE:
   https://github.com/apache/incubator-nuttx-apps/pull/1426/files#diff-df4ad1889816b80fd16d4fa0906888c2f9313974ee14e02acd88231f569c7afcR234
   https://github.com/apache/incubator-nuttx-apps/pull/1426/files#diff-df4ad1889816b80fd16d4fa0906888c2f9313974ee14e02acd88231f569c7afcR372



-- 
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] [incubator-nuttx-apps] xiaoxiang781216 commented on a diff in pull request #1426: Fix clang compiler warning

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #1426:
URL: https://github.com/apache/incubator-nuttx-apps/pull/1426#discussion_r1027120483


##########
examples/foc/foc_fixed16_thr.c:
##########
@@ -185,9 +185,10 @@ int foc_fixed16_thr(FAR struct foc_ctrl_env_s *envp)
   struct foc_mq_s         handle;
   struct foc_motor_b16_s  motor;
   struct foc_device_s     dev;
-  int                     time      = 0;
-  int                     ret       = OK;
+  int                     time = 0;

Review Comment:
   Can't since time is also used in other place:
   https://github.com/apache/incubator-nuttx-apps/pull/1426/files#diff-df4ad1889816b80fd16d4fa0906888c2f9313974ee14e02acd88231f569c7afcR234
   https://github.com/apache/incubator-nuttx-apps/pull/1426/files#diff-df4ad1889816b80fd16d4fa0906888c2f9313974ee14e02acd88231f569c7afcR372



-- 
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