-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix gcc10.1 truncation error #10433
Fix gcc10.1 truncation error #10433
Conversation
gcc10.1 complains with: ../../include/sys/dmu.h:373:24: error: ‘%s’ directive output may be truncated writing up to 95 bytes into a region of size 75 [-Werror=format-truncation=] 373 | #define DMU_POOL_DDT "DDT-%s-%s-%s" | ^~~~~~~~~~~~~~ ../../module/zfs/ddt.c:256:37: note: in expansion of macro ‘DMU_POOL_DDT’ 256 | (void) snprintf(name, DDT_NAMELEN, DMU_POOL_DDT, | ^~~~~~~~~~~~ ../../include/sys/dmu.h:373:32: note: format string is defined here 373 | #define DMU_POOL_DDT "DDT-%s-%s-%s" | ^~ ../../module/zfs/ddt.c:256:9: note: ‘snprintf’ output 7 or more bytes (assuming 102) into a destination of size 80 256 | (void) snprintf(name, DDT_NAMELEN, DMU_POOL_DDT, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 257 | zio_checksum_table[ddt->ddt_checksum].ci_name, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 258 | ddt_ops[type]->ddt_op_name, ddt_class_name[class]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Increasing DTT_NAMELEN fixes it. Signed-off-by: George Amanakis <gamanakis@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #10433 +/- ##
==========================================
+ Coverage 79.46% 79.59% +0.12%
==========================================
Files 391 391
Lines 123866 123866
==========================================
+ Hits 98433 98585 +152
+ Misses 25433 25281 -152
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Increasing the buffer size to silence the warning is fine. But looking at the code I don't see how it determined 102 bytes was the worst case, 80 looks like it should be sufficient for all cases.
That eludes me right now too. |
gcc10.1 complains with: ../../include/sys/dmu.h:373:24: error: ‘%s’ directive output may be truncated writing up to 95 bytes into a region of size 75 [-Werror=format-truncation=] 373 | #define DMU_POOL_DDT "DDT-%s-%s-%s" | ^~~~~~~~~~~~~~ ../../module/zfs/ddt.c:256:37: note: in expansion of macro ‘DMU_POOL_DDT’ 256 | (void) snprintf(name, DDT_NAMELEN, DMU_POOL_DDT, | ^~~~~~~~~~~~ ../../include/sys/dmu.h:373:32: note: format string is defined here 373 | #define DMU_POOL_DDT "DDT-%s-%s-%s" | ^~ ../../module/zfs/ddt.c:256:9: note: ‘snprintf’ output 7 or more bytes (assuming 102) into a destination of size 80 256 | (void) snprintf(name, DDT_NAMELEN, DMU_POOL_DDT, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 257 | zio_checksum_table[ddt->ddt_checksum].ci_name, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 258 | ddt_ops[type]->ddt_op_name, ddt_class_name[class]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Increasing DTT_NAMELEN fixes it. Reviewed-By: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: George Amanakis <gamanakis@gmail.com> Closes #10433
gcc10.1 complains with: ../../include/sys/dmu.h:373:24: error: ‘%s’ directive output may be truncated writing up to 95 bytes into a region of size 75 [-Werror=format-truncation=] 373 | #define DMU_POOL_DDT "DDT-%s-%s-%s" | ^~~~~~~~~~~~~~ ../../module/zfs/ddt.c:256:37: note: in expansion of macro ‘DMU_POOL_DDT’ 256 | (void) snprintf(name, DDT_NAMELEN, DMU_POOL_DDT, | ^~~~~~~~~~~~ ../../include/sys/dmu.h:373:32: note: format string is defined here 373 | #define DMU_POOL_DDT "DDT-%s-%s-%s" | ^~ ../../module/zfs/ddt.c:256:9: note: ‘snprintf’ output 7 or more bytes (assuming 102) into a destination of size 80 256 | (void) snprintf(name, DDT_NAMELEN, DMU_POOL_DDT, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 257 | zio_checksum_table[ddt->ddt_checksum].ci_name, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 258 | ddt_ops[type]->ddt_op_name, ddt_class_name[class]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Increasing DTT_NAMELEN fixes it. Reviewed-By: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: George Amanakis <gamanakis@gmail.com> Closes openzfs#10433 (cherry picked from commit f2edc00)
gcc10.1 complains with: ../../include/sys/dmu.h:373:24: error: ‘%s’ directive output may be truncated writing up to 95 bytes into a region of size 75 [-Werror=format-truncation=] 373 | #define DMU_POOL_DDT "DDT-%s-%s-%s" | ^~~~~~~~~~~~~~ ../../module/zfs/ddt.c:256:37: note: in expansion of macro ‘DMU_POOL_DDT’ 256 | (void) snprintf(name, DDT_NAMELEN, DMU_POOL_DDT, | ^~~~~~~~~~~~ ../../include/sys/dmu.h:373:32: note: format string is defined here 373 | #define DMU_POOL_DDT "DDT-%s-%s-%s" | ^~ ../../module/zfs/ddt.c:256:9: note: ‘snprintf’ output 7 or more bytes (assuming 102) into a destination of size 80 256 | (void) snprintf(name, DDT_NAMELEN, DMU_POOL_DDT, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 257 | zio_checksum_table[ddt->ddt_checksum].ci_name, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 258 | ddt_ops[type]->ddt_op_name, ddt_class_name[class]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Increasing DTT_NAMELEN fixes it. Reviewed-By: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: George Amanakis <gamanakis@gmail.com> Closes openzfs#10433
gcc10.1 complains with: ../../include/sys/dmu.h:373:24: error: ‘%s’ directive output may be truncated writing up to 95 bytes into a region of size 75 [-Werror=format-truncation=] 373 | #define DMU_POOL_DDT "DDT-%s-%s-%s" | ^~~~~~~~~~~~~~ ../../module/zfs/ddt.c:256:37: note: in expansion of macro ‘DMU_POOL_DDT’ 256 | (void) snprintf(name, DDT_NAMELEN, DMU_POOL_DDT, | ^~~~~~~~~~~~ ../../include/sys/dmu.h:373:32: note: format string is defined here 373 | #define DMU_POOL_DDT "DDT-%s-%s-%s" | ^~ ../../module/zfs/ddt.c:256:9: note: ‘snprintf’ output 7 or more bytes (assuming 102) into a destination of size 80 256 | (void) snprintf(name, DDT_NAMELEN, DMU_POOL_DDT, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 257 | zio_checksum_table[ddt->ddt_checksum].ci_name, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 258 | ddt_ops[type]->ddt_op_name, ddt_class_name[class]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Increasing DTT_NAMELEN fixes it. Reviewed-By: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: George Amanakis <gamanakis@gmail.com> Closes openzfs#10433
gcc10.1 complains with: ../../include/sys/dmu.h:373:24: error: ‘%s’ directive output may be truncated writing up to 95 bytes into a region of size 75 [-Werror=format-truncation=] 373 | #define DMU_POOL_DDT "DDT-%s-%s-%s" | ^~~~~~~~~~~~~~ ../../module/zfs/ddt.c:256:37: note: in expansion of macro ‘DMU_POOL_DDT’ 256 | (void) snprintf(name, DDT_NAMELEN, DMU_POOL_DDT, | ^~~~~~~~~~~~ ../../include/sys/dmu.h:373:32: note: format string is defined here 373 | #define DMU_POOL_DDT "DDT-%s-%s-%s" | ^~ ../../module/zfs/ddt.c:256:9: note: ‘snprintf’ output 7 or more bytes (assuming 102) into a destination of size 80 256 | (void) snprintf(name, DDT_NAMELEN, DMU_POOL_DDT, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 257 | zio_checksum_table[ddt->ddt_checksum].ci_name, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 258 | ddt_ops[type]->ddt_op_name, ddt_class_name[class]); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Increasing DTT_NAMELEN fixes it. Reviewed-By: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: George Amanakis <gamanakis@gmail.com> Closes openzfs#10433
After commit c9e319f gcc10.1 complains with:
Increasing DTT_NAMELEN fixes it.
Signed-off-by: George Amanakis gamanakis@gmail.com
Motivation and Context
Description
How Has This Been Tested?
Types of changes
Checklist:
Signed-off-by
.