You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2020/10/24 06:56:08 UTC

[GitHub] [mynewt-core] caspermeijn opened a new pull request #2402: hw/battery: Fix strncpy warning

caspermeijn opened a new pull request #2402:
URL: https://github.com/apache/mynewt-core/pull/2402


   GCC complains about a strncpy call when building using build_profile speed.
   This warning indicates a possible string truncation. The only proper
   solution I could find was to decrease the buf_size and explicitly set a
   zero byte.
   
   Error: In function 'battery_prop_get_name',
       inlined from 'battery_find_property_by_name' at repos/apache-mynewt-core/hw/battery/src/battery.c:392:9:
   repos/apache-mynewt-core/hw/battery/src/battery.c:379:5: error: 'strncpy' specified bound 20 equals destination size [-Werror=stringop-truncation]
     379 |     strncpy(buf, driver_prop->bdp_name, buf_size);
         |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   cc1: all warnings being treated as errors


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

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



[GitHub] [mynewt-core] apache-mynewt-bot commented on pull request #2402: hw/battery: Fix strncpy warning

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on pull request #2402:
URL: https://github.com/apache/mynewt-core/pull/2402#issuecomment-715919791


   
   <!-- style-bot -->
   
   ## Style check summary
   
   #### No suggestions at this time!
   


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

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



[GitHub] [mynewt-core] apache-mynewt-bot commented on pull request #2402: hw/battery: Fix strncpy warning

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on pull request #2402:
URL: https://github.com/apache/mynewt-core/pull/2402#issuecomment-715820537


   
   <!-- style-bot -->
   
   ## Style check summary
   
   ### Our coding style is [here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
   #### hw/battery/src/battery.c
   <details>
   
   ```diff
   @@ -369,12 +368,12 @@
    
    char *
    battery_prop_get_name(const struct battery_property *prop, char *buf,
   -        size_t buf_size)
   +                      size_t buf_size)
    {
        struct battery *bat = battery_manager.bm_batteries[prop->bp_bat_num];
        struct battery_driver *driver = bat->b_drivers[prop->bp_drv_num];
        const struct battery_driver_property *driver_prop =
   -            &driver->bd_driver_properties[prop->bp_prop_num - driver->bd_first_property];
   +        &driver->bd_driver_properties[prop->bp_prop_num - driver->bd_first_property];
    
        strncpy(buf, driver_prop->bdp_name, buf_size - 1);
        buf[buf_size - 1] = '\0';
   ```
   
   </details>


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

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



[GitHub] [mynewt-core] kasjer merged pull request #2402: hw/battery: Fix strncpy warning

Posted by GitBox <gi...@apache.org>.
kasjer merged pull request #2402:
URL: https://github.com/apache/mynewt-core/pull/2402


   


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

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



[GitHub] [mynewt-core] apache-mynewt-bot removed a comment on pull request #2402: hw/battery: Fix strncpy warning

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot removed a comment on pull request #2402:
URL: https://github.com/apache/mynewt-core/pull/2402#issuecomment-715919387


   
   <!-- style-bot -->
   
   ## Style check summary
   
   ### Our coding style is [here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
   #### hw/battery/src/battery_shell.c
   <details>
   
   ```diff
   @@ -503,7 +503,7 @@
    
        if (argc < 2) {
            rc = SYS_EINVAL;
   -    } else   {
   +    } else {
            for (i = 0; bat_cli_commands[i].sc_cmd; ++i) {
                if (strcmp(bat_cli_commands[i].sc_cmd, argv[1]) == 0) {
                    rc = bat_cli_commands[i].sc_cmd_func(argc - 1, argv + 1);
   ```
   
   </details>


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

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



[GitHub] [mynewt-core] apache-mynewt-bot commented on pull request #2402: hw/battery: Fix strncpy warning

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot commented on pull request #2402:
URL: https://github.com/apache/mynewt-core/pull/2402#issuecomment-715919387


   
   <!-- style-bot -->
   
   ## Style check summary
   
   ### Our coding style is [here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
   #### hw/battery/src/battery_shell.c
   <details>
   
   ```diff
   @@ -503,7 +503,7 @@
    
        if (argc < 2) {
            rc = SYS_EINVAL;
   -    } else   {
   +    } else {
            for (i = 0; bat_cli_commands[i].sc_cmd; ++i) {
                if (strcmp(bat_cli_commands[i].sc_cmd, argv[1]) == 0) {
                    rc = bat_cli_commands[i].sc_cmd_func(argc - 1, argv + 1);
   ```
   
   </details>


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

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



[GitHub] [mynewt-core] apache-mynewt-bot removed a comment on pull request #2402: hw/battery: Fix strncpy warning

Posted by GitBox <gi...@apache.org>.
apache-mynewt-bot removed a comment on pull request #2402:
URL: https://github.com/apache/mynewt-core/pull/2402#issuecomment-715820537


   
   <!-- style-bot -->
   
   ## Style check summary
   
   ### Our coding style is [here!](https://github.com/apache/mynewt-core/blob/master/CODING_STANDARDS.md)
   
   
   #### hw/battery/src/battery.c
   <details>
   
   ```diff
   @@ -369,12 +368,12 @@
    
    char *
    battery_prop_get_name(const struct battery_property *prop, char *buf,
   -        size_t buf_size)
   +                      size_t buf_size)
    {
        struct battery *bat = battery_manager.bm_batteries[prop->bp_bat_num];
        struct battery_driver *driver = bat->b_drivers[prop->bp_drv_num];
        const struct battery_driver_property *driver_prop =
   -            &driver->bd_driver_properties[prop->bp_prop_num - driver->bd_first_property];
   +        &driver->bd_driver_properties[prop->bp_prop_num - driver->bd_first_property];
    
        strncpy(buf, driver_prop->bdp_name, buf_size - 1);
        buf[buf_size - 1] = '\0';
   ```
   
   </details>


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

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