Fix some GCC warnings
cover Fix some GCC warnings
During the compilation, some GCC (8.1) warnings are shown. This patchset address some of the warnings problems.
Rodrigo Siqueira (3):
Avoid truncate string in __igt_lsof_fds Remove extra '\0' in strncpy in igt_save_module_param Move declaration to the top of the code
lib/igt_aux.c | 4 ++-- lib/igt_color_encoding.c | 16 ++++++---------- tests/kms_frontbuffer_tracking.c | 2 +- 3 files changed, 9 insertions(+), 13 deletions(-)
Signature · 6 lines
2.17.0 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 1/3 Avoid truncate string in __igt_lsof_fds
Note that 'proc_path' parameter in __igt_lsof_fds receives a string which was initialized with the size of PATH_MAX and the local variable 'path' has the same size, but it also have to append: '/', '\0', and the directory name. This situation caused the warning described below.
warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size between 0 and 4095 [-Wformat-truncation=] snprintf(path, sizeof(path), "%s/%s", proc_path, d->d_name);
note: ‘snprintf’ output between 2 and 4352 bytes into a destination of size 4096 [..]
This patch fix the above problem.
--- lib/igt_aux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/igt_aux.c +1 -1
@@ -1425,7 +1425,7 @@ __igt_lsof_fds(proc_t *proc_info, int *state, char *proc_path, const char *dir) {struct dirent *d;struct stat st; -char path[PATH_MAX ]; +char path[PATH_MAX +NAME_MAX +2 ];// 1 byte for '/' and another for '\0' char *fd_lnk;/* default fds or kernel threads */
Signature · 6 lines
2.17.0 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 2/3 Remove extra '\0' in strncpy in igt_save_module_param
In reply to Rodrigo SiqueiraThis patch fix the following gcc warning:
warning: ‘strncpy’ specified bound 32 equals destination size [-Wstringop-truncation]
strncpy(data->name, name, PARAM_NAME_MAX_SZ);
This error happens due to the '\0' character appended by strncpy. Notice that reduces by one in the total of bytes to be copied, in this case, is harmless because the strings received in the parameter already have '\0'.
--- lib/igt_aux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/igt_aux.c +1 -1
@@ -1240,7 +1240,7 @@ static void igt_save_module_param(const char *name, const char *file_path) data =calloc (1 ,sizeof (*data));igt_assert (data); -strncpy (data->name, name,PARAM_NAME_MAX_SZ ); +strncpy (data->name, name,PARAM_NAME_MAX_SZ -1 );// -1 because of '\0' fd =open (file_path,O_RDONLY );igt_assert (fd >=0 );
Signature · 6 lines
2.17.0 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
PATCH 3/3 Move declaration to the top of the code
In reply to Rodrigo SiqueiraThis patch fix the following gcc warnings:
warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] [..] igt_color_encoding.c:45:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] [..] igt_color_encoding.c: In function ‘ycbcr_to_rgb_matrix’:
igt_color_encoding.c:72:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] [..]
--- lib/igt_color_encoding.c | 16 ++++++---------- tests/kms_frontbuffer_tracking.c | 2 +- 2 files changed, 7 insertions(+), 11 deletions(-)
lib/igt_color_encoding.c +6 -10
@@ -36,11 +36,9 @@ static const struct color_encoding color_encodings[IGT_NUM_COLOR_ENCODINGS] = {static struct igt_mat4 rgb_to_ycbcr_matrix (const struct color_encoding *e) { -float kr, kg, kb; - - kr = e->kr; - kb = e->kb; - kg =1.0f - kr - kb; +float kr = e->kr; +float kb = e->kb; +float kg =1.0f - kr - kb;struct igt_mat4 ret = { .d[0 *4 +0 ] = kr,
@@ -63,11 +61,9 @@ static struct igt_mat4 rgb_to_ycbcr_matrix(const struct color_encoding *e)static struct igt_mat4 ycbcr_to_rgb_matrix (const struct color_encoding *e) { -float kr, kg, kb; - - kr = e->kr; - kb = e->kb; - kg =1.0f - kr - kb; +float kr = e->kr; +float kb = e->kb; +float kg =1.0f - kr - kb;struct igt_mat4 ret = { .d[0 *4 +0 ] =1.0f ,
tests/kms_frontbuffer_tracking.c +1 -1
@@ -1770,8 +1770,8 @@ static void do_status_assertions(int flags)static void __do_assertions (const struct test_mode *t,int flags,int line) { - flags =adjust_assertion_flags (t, flags);bool mandatory_sink_crc = t->feature &FEATURE_PSR ; + flags =adjust_assertion_flags (t, flags);igt_debug ("checking asserts in line %i\n" , line);
Signature · 6 lines
2.17.0 _______________________________________________ igt-dev mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/igt-dev
Patchwork
CI[igt-dev] ✓ Fi.CI.BAT: success for Fix some GCC warnings
In reply to Rodrigo Siqueira== Series Details ==
== Series Details ==
Series: Fix some GCC warnings
URL : https://patchwork.freedesktop.org/series/43913/
State : success
== Summary ==
= CI Bug Log - changes from CI_DRM_4255 -> IGTPW_1407 =
== Summary - WARNING ==
Minor unknown changes coming with IGTPW_1407 need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in IGTPW_1407, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.
External URL: https://patchwork.freedesktop.org/api/1.0/series/43913/revisions/1/mbox/
== Possible new issues ==
Here are the unknown changes that may have been introduced in IGTPW_1407:
=== IGT changes ===
==== Warnings ====
igt@gem_exec_gttfill@basic:
fi-pnv-d510: PASS -> SKIP== Known issues ==
Here are the changes found in IGTPW_1407 that come from known issues:
=== IGT changes ===
==== Issues hit ====
igt@drv_module_reload@basic-reload-inject:
fi-glk-j4005: PASS -> DMESG-WARN (fdo#106097)
igt@gem_ctx_create@basic-files:
fi-glk-j4005: PASS -> DMESG-WARN (fdo#105719)
igt@kms_flip@basic-plain-flip:
fi-glk-j4005: PASS -> DMESG-WARN (fdo#106000)
==== Possible fixes ====
igt@gem_exec_suspend@basic-s3:
fi-glk-j4005: DMESG-WARN (fdo#106097) -> PASS +1
igt@gem_mmap_gtt@basic-small-bo-tiledx:
fi-gdg-551: FAIL (fdo#102575) -> PASS
igt@gem_mmap_gtt@basic-wc:
fi-glk-j4005: DMESG-WARN (fdo#105719) -> PASS
igt@kms_chamelium@dp-edid-read:
fi-kbl-7500u: FAIL (fdo#103841) -> PASS
igt@kms_flip@basic-flip-vs-modeset:
fi-glk-j4005: DMESG-WARN (fdo#106000) -> PASS
igt@kms_pipe_crc_basic@read-crc-pipe-b-frame-sequence:
fi-glk-j4005: FAIL (fdo#103481) -> PASS
igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
fi-cnl-psr: DMESG-WARN (fdo#104951) -> PASS fdo#102575 https://bugs.freedesktop.org/show_bug.cgi?id=102575
fdo#103481 https://bugs.freedesktop.org/show_bug.cgi?id=103481
fdo#103841 https://bugs.freedesktop.org/show_bug.cgi?id=103841
fdo#104951 https://bugs.freedesktop.org/show_bug.cgi?id=104951
fdo#105719 https://bugs.freedesktop.org/show_bug.cgi?id=105719
fdo#106000 https://bugs.freedesktop.org/show_bug.cgi?id=106000
fdo#106097 https://bugs.freedesktop.org/show_bug.cgi?id=106097
== Participating hosts (45 -> 39) ==
Missing (6): fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-cfl-u2 fi-skl-6700hq
== Build changes ==
* IGT: IGT_4499 -> IGTPW_1407
CI_DRM_4255: 5550ce1b359dcbd8d9387e0501bc372f0c158eaa @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_1407: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1407/
IGT_4499: f560ae5a464331f03f0a669ed46b8c9e56526187 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1407/issues.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Patchwork
CI[igt-dev] ✗ Fi.CI.IGT: failure for Fix some GCC warnings
In reply to Rodrigo Siqueira== Series Details ==
== Series Details ==
Series: Fix some GCC warnings
URL : https://patchwork.freedesktop.org/series/43913/
State : failure
== Summary ==
= CI Bug Log - changes from IGT_4499_full -> IGTPW_1407_full =
== Summary - FAILURE ==
Serious unknown changes coming with IGTPW_1407_full absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in IGTPW_1407_full, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.
External URL: https://patchwork.freedesktop.org/api/1.0/series/43913/revisions/1/mbox/
== Possible new issues ==
Here are the unknown changes that may have been introduced in IGTPW_1407_full:
=== IGT changes ===
==== Possible regressions ====
igt@kms_vblank@pipe-a-ts-continuation-dpms-suspend:
shard-snb: PASS -> DMESG-WARN
==== Warnings ====
igt@gem_shrink@reclaim:
shard-snb: PASS -> SKIP== Known issues ==
Here are the changes found in IGTPW_1407_full that come from known issues:
=== IGT changes ===
==== Issues hit ====
igt@drv_selftest@live_gtt:
shard-apl: PASS -> INCOMPLETE (fdo#103927)
igt@gem_ppgtt@blt-vs-render-ctx0:
shard-kbl: PASS -> INCOMPLETE (fdo#106023, fdo#103665)
igt@gem_softpin@noreloc-s3:
shard-snb: PASS -> INCOMPLETE (fdo#105411)
igt@kms_atomic_transition@1x-modeset-transitions-nonblocking:
shard-glk: PASS -> FAIL (fdo#105703)
igt@kms_flip@2x-wf_vblank-ts-check-interruptible:
shard-glk: PASS -> FAIL (fdo#100368) +1
igt@kms_flip_tiling@flip-to-y-tiled:
shard-glk: PASS -> FAIL (fdo#104724, fdo#103822) +1
==== Possible fixes ====
{igt@kms_available_modes_crc@available_mode_test_crc}:
shard-snb: FAIL (fdo#106641) -> PASS
igt@kms_cursor_crc@cursor-256x256-suspend:
shard-kbl: INCOMPLETE (fdo#103665) -> PASS +1
igt@kms_flip@plain-flip-fb-recreate-interruptible:
shard-glk: FAIL (fdo#100368) -> PASS +1
igt@kms_flip_tiling@flip-x-tiled:
shard-glk: FAIL (fdo#104724, fdo#103822) -> PASS
igt@kms_plane_multiple@atomic-pipe-a-tiling-x:
shard-snb: FAIL (fdo#104724, fdo#103166) -> PASS
igt@kms_rotation_crc@primary-rotation-180:
shard-snb: FAIL (fdo#104724, fdo#103925) -> PASS
igt@kms_setmode@basic:
shard-kbl: FAIL (fdo#99912) -> PASS {name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#103166 https://bugs.freedesktop.org/show_bug.cgi?id=103166
fdo#103665 https://bugs.freedesktop.org/show_bug.cgi?id=103665
fdo#103822 https://bugs.freedesktop.org/show_bug.cgi?id=103822
fdo#103925 https://bugs.freedesktop.org/show_bug.cgi?id=103925
fdo#103927 https://bugs.freedesktop.org/show_bug.cgi?id=103927
fdo#104724 https://bugs.freedesktop.org/show_bug.cgi?id=104724
fdo#105411 https://bugs.freedesktop.org/show_bug.cgi?id=105411
fdo#105703 https://bugs.freedesktop.org/show_bug.cgi?id=105703
fdo#106023 https://bugs.freedesktop.org/show_bug.cgi?id=106023
fdo#106641 https://bugs.freedesktop.org/show_bug.cgi?id=106641
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
== Participating hosts (5 -> 5) ==
No changes in participating hosts
== Build changes ==
* IGT: IGT_4499 -> IGTPW_1407
* Linux: CI_DRM_4238 -> CI_DRM_4255
CI_DRM_4238: 2771a5e6347eb63e43fdfc432a9f15ffb55ef209 @ git://anongit.freedesktop.org/gfx-ci/linux
CI_DRM_4255: 5550ce1b359dcbd8d9387e0501bc372f0c158eaa @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_1407: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1407/
IGT_4499: f560ae5a464331f03f0a669ed46b8c9e56526187 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1407/shards.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Patchwork
CI[igt-dev] ✓ Fi.CI.BAT: success for Fix some GCC warnings
In reply to Rodrigo Siqueira== Series Details ==
== Series Details ==
Series: Fix some GCC warnings
URL : https://patchwork.freedesktop.org/series/43913/
State : success
== Summary ==
= CI Bug Log - changes from CI_DRM_4269 -> IGTPW_1412 =
== Summary - SUCCESS ==
No regressions found.
External URL: https://patchwork.freedesktop.org/api/1.0/series/43913/revisions/1/mbox/
== Known issues ==
Here are the changes found in IGTPW_1412 that come from known issues:
=== IGT changes ===
==== Issues hit ====
igt@debugfs_test@read_all_entries:
fi-bdw-gvtdvm: PASS -> DMESG-WARN (fdo#105600) +2
igt@gem_exec_suspend@basic-s3:
fi-bdw-gvtdvm: PASS -> INCOMPLETE (fdo#105600)
fi-skl-gvtdvm: PASS -> INCOMPLETE (fdo#105600, fdo#104108)
igt@gem_mmap_gtt@basic-small-bo-tiledx:
fi-gdg-551: PASS -> FAIL (fdo#102575)
igt@kms_flip@basic-plain-flip:
fi-glk-j4005: PASS -> DMESG-WARN (fdo#106097)
==== Possible fixes ====
igt@drv_module_reload@basic-reload-inject:
fi-glk-j4005: DMESG-WARN (fdo#106248, fdo#106725) -> PASS
igt@gem_exec_suspend@basic-s3:
fi-skl-6700k2: INCOMPLETE (k.org#199541, fdo#104108, fdo#105524) -> PASS
igt@kms_busy@basic-flip-c:
fi-glk-j4005: FAIL (fdo#103182) -> PASS
igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c:
fi-kbl-7567u: FAIL (fdo#103191, fdo#104724) -> PASS fdo#102575 https://bugs.freedesktop.org/show_bug.cgi?id=102575
fdo#103182 https://bugs.freedesktop.org/show_bug.cgi?id=103182
fdo#103191 https://bugs.freedesktop.org/show_bug.cgi?id=103191
fdo#104108 https://bugs.freedesktop.org/show_bug.cgi?id=104108
fdo#104724 https://bugs.freedesktop.org/show_bug.cgi?id=104724
fdo#105524 https://bugs.freedesktop.org/show_bug.cgi?id=105524
fdo#105600 https://bugs.freedesktop.org/show_bug.cgi?id=105600
fdo#106097 https://bugs.freedesktop.org/show_bug.cgi?id=106097
fdo#106248 https://bugs.freedesktop.org/show_bug.cgi?id=106248
fdo#106725 https://bugs.freedesktop.org/show_bug.cgi?id=106725
k.org#199541 https://bugzilla.kernel.org/show_bug.cgi?id=199541
== Participating hosts (43 -> 38) ==
Missing (5): fi-ctg-p8600 fi-ilk-m540 fi-cnl-y3 fi-skl-6700hq fi-cfl-u
== Build changes ==
* IGT: IGT_4503 -> IGTPW_1412
CI_DRM_4269: 25dda01a94cbf70d599be9b0f74c61f310858fa3 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_1412: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1412/
IGT_4503: ae0ea2a0cff1cf8516d18ada5b9db01c56b73ed9 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1412/issues.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Patchwork
CI[igt-dev] ✓ Fi.CI.IGT: success for Fix some GCC warnings
In reply to Rodrigo Siqueira== Series Details ==
== Series Details ==
Series: Fix some GCC warnings
URL : https://patchwork.freedesktop.org/series/43913/
State : success
== Summary ==
= CI Bug Log - changes from IGT_4503_full -> IGTPW_1412_full =
== Summary - WARNING ==
Minor unknown changes coming with IGTPW_1412_full need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in IGTPW_1412_full, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.
External URL: https://patchwork.freedesktop.org/api/1.0/series/43913/revisions/1/mbox/
== Possible new issues ==
Here are the unknown changes that may have been introduced in IGTPW_1412_full:
=== IGT changes ===
==== Warnings ====
igt@gem_exec_schedule@deep-bsd1:
shard-kbl: SKIP -> PASS +2
igt@gem_exec_schedule@deep-bsd2:
shard-kbl: PASS -> SKIP +2
igt@perf_pmu@cpu-hotplug:
shard-apl: SKIP -> PASS== Known issues ==
Here are the changes found in IGTPW_1412_full that come from known issues:
=== IGT changes ===
==== Issues hit ====
igt@gem_exec_await@wide-contexts:
shard-glk: PASS -> FAIL (fdo#105900)
igt@gem_wait@wait-render:
shard-snb: PASS -> INCOMPLETE (fdo#105411)
igt@kms_available_modes_crc@available_mode_test_crc:
shard-snb: PASS -> FAIL (fdo#106641)
igt@kms_flip@2x-plain-flip-fb-recreate-interruptible:
shard-hsw: PASS -> FAIL (fdo#100368)
shard-glk: PASS -> FAIL (fdo#100368)
igt@kms_flip_tiling@flip-to-y-tiled:
shard-glk: PASS -> FAIL (fdo#104724, fdo#103822)
igt@kms_plane_scaling@pipe-a-scaler-with-clipping-clamping:
shard-glk: PASS -> DMESG-WARN (fdo#105763)
==== Possible fixes ====
igt@drv_selftest@live_gtt:
shard-kbl: INCOMPLETE (fdo#103665) -> PASS
igt@gem_exec_store@cachelines-vebox:
shard-snb: INCOMPLETE (fdo#105411) -> SKIP
igt@kms_atomic_transition@1x-modeset-transitions-nonblocking:
shard-glk: FAIL (fdo#105703) -> PASS
igt@kms_flip_tiling@flip-to-x-tiled:
shard-glk: FAIL (fdo#104724) -> PASS
igt@testdisplay:
shard-glk: INCOMPLETE (k.org#198133, fdo#103359) -> PASS fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#103359 https://bugs.freedesktop.org/show_bug.cgi?id=103359
fdo#103665 https://bugs.freedesktop.org/show_bug.cgi?id=103665
fdo#103822 https://bugs.freedesktop.org/show_bug.cgi?id=103822
fdo#104724 https://bugs.freedesktop.org/show_bug.cgi?id=104724
fdo#105411 https://bugs.freedesktop.org/show_bug.cgi?id=105411
fdo#105703 https://bugs.freedesktop.org/show_bug.cgi?id=105703
fdo#105763 https://bugs.freedesktop.org/show_bug.cgi?id=105763
fdo#105900 https://bugs.freedesktop.org/show_bug.cgi?id=105900
fdo#106641 https://bugs.freedesktop.org/show_bug.cgi?id=106641
k.org#198133 https://bugzilla.kernel.org/show_bug.cgi?id=198133
== Participating hosts (5 -> 5) ==
No changes in participating hosts
== Build changes ==
* IGT: IGT_4503 -> IGTPW_1412
* Linux: CI_DRM_4265 -> CI_DRM_4269
CI_DRM_4265: 1bef5a8b1f02a5a612ac38bc6d7950becc2a9aa8 @ git://anongit.freedesktop.org/gfx-ci/linux
CI_DRM_4269: 25dda01a94cbf70d599be9b0f74c61f310858fa3 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_1412: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1412/
IGT_4503: ae0ea2a0cff1cf8516d18ada5b9db01c56b73ed9 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_1412/shards.html
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [Intel-gfx] [PATCH i-g-t 1/3] Avoid truncate string in __igt_lsof_fds
In reply to Rodrigo SiqueiraQuoted 23 lines · Rodrigo Siqueira
Note that '
proc_path' parameter in__igt_lsof_fdsreceives a string which was initialized with the size ofPATH_MAXand the local variable 'path' has the same size, but it also have to append: '/', '\0', and the directory name. This situation caused the warning described below.warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size between 0 and 4095 [-Wformat-truncation=]
snprintf(path, sizeof(path), "%s/%s", proc_path, d->d_name);
note: ‘snprintf’ output between 2 and 4352 bytes into a destination of size 4096 [..]This patch fix the above problem.
Signed-off-by Rodrigo Siqueira <[email protected]>--- lib/igt_aux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/igt_aux.c +0
-0
lib/igt_aux.c __igt_lsof_fds(proc_t *proc_info, int *state, char *proc_path, const char *dir) · line 1428
Quoted 5 lines
lib/igt_aux.c +1
-1@@ -1425,7 +1425,7 @@ __igt_lsof_fds(proc_t *proc_info, int *state, char *proc_path, const char *dir) {struct dirent *d;struct stat st; -char path[PATH_MAX ]; +char path[PATH_MAX +NAME_MAX +2 ];// 1 byte for '/' and another for '\0'
Hey,
First of, thanks for looking at the new warnings. We definitely have to fix those :-)
A couple of lines down we have lstat(path, &st), which will return -1 with errno == ENAMETOOLONG if we go over PATH_MAX, so this does not feel right, especially that we are not checking for that.
Digging deeper, __igt_lsof_fds() is used only inside __igt_lsof(), which is the reason for such a high estimate.
It uses char path[PATH_MAX], which is the main contributing component, but it contains at most strlen("/proc/%d/cwd")+1 where "%d" is CEILING(LOG_10(INT_MAX)).
Limiting size of path there to sensible upper estimation should make us fit in PATH_MAX in __igt_lsof_fds (or even less).
Signature · 6 lines
Cheers, Arek _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [igt-dev] [PATCH i-g-t 3/3] Move declaration to the top of the code
In reply to Rodrigo SiqueiraQuoted 11 lines · Rodrigo Siqueira
This patch fix the following gcc warnings:
warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] [..] igt_color_encoding.c:45:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] [..]
igt_color_encoding.c: In function ‘ycbcr_to_rgb_matrix’:
igt_color_encoding.c:72:2: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement] [..]Signed-off-by Rodrigo Siqueira <[email protected]>
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
Re: [Intel-gfx] [PATCH i-g-t 2/3] Remove extra '\0' in strncpy in igt_save_module_param
In reply to Rodrigo SiqueiraTitle is slightly missleading. We don't remove extra NULL characer from anywhere. We just account for it by subtracting 1 from the destination buffer size.
So maybe "Account for NULL character when using strncpy"?
Quoted 21 lines · Rodrigo Siqueira
This patch fix the following gcc warning:
warning: ‘strncpy’ specified bound 32 equals destination size [-Wstringop-truncation]
strncpy(data->name, name, PARAM_NAME_MAX_SZ);This error happens due to the '\0' character appended by strncpy. Notice that reduces by one in the total of bytes to be copied, in this case, is harmless because the strings received in the parameter already have '\0'.
Signed-off-by Rodrigo Siqueira <[email protected]>--- lib/igt_aux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/igt_aux.c +0
-0
lib/igt_aux.c static void igt_save_module_param(const char *name, const char *file_path) · line 1243
Quoted 5 lines
lib/igt_aux.c +1
-1@@ -1240,7 +1240,7 @@ static void igt_save_module_param(const char *name, const char *file_path) data =calloc (1 ,sizeof (*data));igt_assert (data); -strncpy (data->name, name,PARAM_NAME_MAX_SZ ); +strncpy (data->name, name,PARAM_NAME_MAX_SZ -1 );// -1 because of '\0'
I am not necessary sure that the comment is needed, as "buflen - 1" is quite typical.
Signature · 6 lines
Cheers, Arek _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [igt-dev] [PATCH i-g-t 1/3] Avoid truncate string in __igt_lsof_fds
In reply to Arkadiusz HilerHi Arkadiusz,
First of all, thanks for the review.
I believe that I understood all the comments you made in all of the patches. I will send the V2 soon.
Thanks!
Best Regards
Rodrigo Siqueira
Quoted 42 lines · Arkadiusz Hiler
Quoted 23 lines · Rodrigo Siqueira
Note that '
proc_path' parameter in__igt_lsof_fdsreceives a string which was initialized with the size ofPATH_MAXand the local variable 'path' has the same size, but it also have to append: '/', '\0', and the directory name. This situation caused the warning described below.warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size between 0 and 4095 [-Wformat-truncation=]
snprintf(path, sizeof(path), "%s/%s", proc_path, d->d_name);
note: ‘snprintf’ output between 2 and 4352 bytes into a destination of size 4096 [..]This patch fix the above problem.
Signed-off-by Rodrigo Siqueira <[email protected]>--- lib/igt_aux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)lib/igt_aux.c +0
-0lib/igt_aux.c __igt_lsof_fds(proc_t *proc_info, int *state, char *proc_path, const char *dir) · line 1428
Quoted 5 lines
lib/igt_aux.c +1
-1@@ -1425,7 +1425,7 @@ __igt_lsof_fds(proc_t *proc_info, int *state, char *proc_path, const char *dir) {struct dirent *d;struct stat st; -char path[PATH_MAX ]; +char path[PATH_MAX +NAME_MAX +2 ];// 1 byte for '/' and another for '\0' Hey,
First of, thanks for looking at the new warnings. We definitely have to fix those :-)
A couple of lines down we have
lstat(path, &st), which will return -1 with errno == ENAMETOOLONG if we go overPATH_MAX, so this does not feel right, especially that we are not checking for that.Digging deeper,
__igt_lsof_fds()is used only inside__igt_lsof(), which is the reason for such a high estimate.
Quoted 10 lines
It uses char path[PATH_MAX], which is the main contributing component, but it contains at most strlen("/proc/%d/cwd")+1 where "%d" is CEILING(LOG_10(INT_MAX)).
Limiting size of path there to sensible upper estimation should make us fit in
PATH_MAXin__igt_lsof_fds(or even less).Signature · 2 lines
Cheers, Arek
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev