lib/xe/xe_gt: Repair xe_gt_stats_get_count function
PATCH 1/1 lib/xe/xe_gt: Repair xe_gt_stats_get_count function
Resolve the following issues:
- The target directory for the fopen does not take into consideration the dri subdirectory and assumes the correct path is dri/0. This might not be the case. Use the "minor" function and fstat to generate the correct subdirectory.
- The fopen may fail and return a NULL pointer, causing the subsequent fgets to generate a SIGSEGV. Assert the file opened correctly.
- The file opened by fopen is never closed. Close it.
--- lib/xe/xe_gt.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
lib/xe/xe_gt.c +11 -1
@@ -152,18 +152,28 @@ void xe_post_hang_ring(int fd, igt_hang_t arg)int xe_gt_stats_get_count (int fd,int gt,const char *stat) {FILE *f; +struct stat st;char tlb_path[4096 ];char path[256 ];int count; -sprintf (path,"/sys/kernel/debug/dri/0/gt%d/stats" , gt); +igt_assert_eq (fstat (fd, &st),0 ); + +sprintf (path,"/sys/kernel/debug/dri/%d/gt%d/stats" , +minor (st.st_rdev), gt); f =fopen (path,"r" ); +igt_assert_f (f,"Failed to open /sys/kernel/debug/dri/%d/gt%d/stats" , +minor (st.st_rdev), gt); +while (fgets (tlb_path,sizeof (tlb_path), f)) {if (strstr (tlb_path, stat) !=NULL ) {sscanf (tlb_path,"%*[^:]: %d" , &count);break ; } } + +close (f); +return count; }
Signature · 1 line
2.43.0
Patchwork
CI✗ GitLab.Pipeline: warning for lib/xe/xe_gt: Repair xe_gt_stats_get_count function
== Series Details ==
== Series Details ==
Series: lib/xe/xe_gt: Repair xe_gt_stats_get_count function
URL : https://patchwork.freedesktop.org/series/142124/
State : warning
== Summary ==
Pipeline status: FAILED.
see https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/pipelines/1323511 for the overview.
build:tests-debian-meson has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/67728241):
[4/1770] Compiling C object 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o'.
FAILED: lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o
cc -Ilib/76b5a35@@igt-xe_xe_gt_c@sta -Ilib -I../lib -I../include -I../include/drm-uapi -I../include/drm-uapi-experimental -I../include/linux-uapi -I../lib/stubs/syscalls -I. -I../ -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libdrm -I/usr/include/libdrm/nouveau -I/usr/include/x86_64-linux-gnu -I/usr/include/valgrind -I/usr/include/alsa -I/usr/include -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O2 -g -D_GNU_SOURCE -include config.h -D_FORTIFY_SOURCE=2 -Wbad-function-cast -Wdeclaration-after-statement -Wformat=2 -Wimplicit-fallthrough=0 -Wlogical-op -Wmissing-declarations -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wuninitialized -Wunused -Wno-clobbered -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-pointer-arith -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter -Wno-unused-result -Werror=address -Werror=array-bounds -Werror=implicit -Werror=init-self -Werror=int-conversion -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=nonnull -Werror=pointer-to-int-cast -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=write-strings -fno-builtin-malloc -fno-builtin-calloc -D_LARGEFILE64_SOURCE=1 -fPIC -pthread '-DIGT_DATADIR="/usr/local/share/igt-gpu-tools"' '-DIGT_SRCDIR="/builds/gfx-ci/igt-ci-tags/tests"' '-DIGT_LOG_DOMAIN="xe/xe_gt"' -MD -MQ 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -MF 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o.d' -o 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -c ../lib/xe/xe_gt.c ../lib/xe/xe_gt.c: In function ‘xe_gt_stats_get_count’:
../lib/xe/xe_gt.c:176:8: error: passing argument 1 of ‘close’ makes integer from pointer without a cast [-Werror=int-conversion]
close(f);
^
In file included from ../lib/igt_core.h:46,
from ../lib/xe/xe_gt.c:12:
/usr/include/unistd.h:353:23: note: expected ‘int’ but argument is of type ‘FILE *’ {aka ‘struct _IO_FILE *’}
extern int close (int __fd);
~~~~^~~~ cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed. section_end:1733340513:step_script section_start:1733340513:cleanup_file_variables Cleaning up project directory and file based variables section_end:1733340514:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-debian-meson-arm64 has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/67728244):
[6/1400] Compiling C object 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o'.
FAILED: lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o
/usr/bin/aarch64-linux-gnu-gcc -Ilib/76b5a35@@igt-xe_xe_gt_c@sta -Ilib -I../lib -I../include -I../include/drm-uapi -I../include/drm-uapi-experimental -I../include/linux-uapi -I../lib/stubs/syscalls -I. -I../ -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/aarch64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libdrm -I/usr/include/libdrm/nouveau -I/usr/include/aarch64-linux-gnu -I/usr/include/valgrind -I/usr/include/alsa -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O2 -g -D_GNU_SOURCE -include config.h -D_FORTIFY_SOURCE=2 -Wbad-function-cast -Wdeclaration-after-statement -Wformat=2 -Wimplicit-fallthrough=0 -Wlogical-op -Wmissing-declarations -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wuninitialized -Wunused -Wno-clobbered -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-pointer-arith -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter -Wno-unused-result -Werror=address -Werror=array-bounds -Werror=implicit -Werror=init-self -Werror=int-conversion -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=nonnull -Werror=pointer-to-int-cast -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=write-strings -fno-builtin-malloc -fno-builtin-calloc -D_LARGEFILE64_SOURCE=1 -fPIC -pthread '-DIGT_DATADIR="/usr/local/share/igt-gpu-tools"' '-DIGT_SRCDIR="/builds/gfx-ci/igt-ci-tags/tests"' '-DIGT_LOG_DOMAIN="xe/xe_gt"' -MD -MQ 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -MF 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o.d' -o 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -c ../lib/xe/xe_gt.c ../lib/xe/xe_gt.c: In function ‘xe_gt_stats_get_count’:
../lib/xe/xe_gt.c:176:8: error: passing argument 1 of ‘close’ makes integer from pointer without a cast [-Werror=int-conversion]
close(f);
^
In file included from ../lib/igt_core.h:46,
from ../lib/xe/xe_gt.c:12:
/usr/aarch64-linux-gnu/include/unistd.h:353:23: note: expected ‘int’ but argument is of type ‘FILE *’ {aka ‘struct _IO_FILE *’}
extern int close (int __fd);
~~~~^~~~ cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed. section_end:1733340534:step_script section_start:1733340534:cleanup_file_variables Cleaning up project directory and file based variables section_end:1733340537:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-debian-meson-armhf has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/67728243):
[7/1410] Compiling C object 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o'.
FAILED: lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o
/usr/bin/arm-linux-gnueabihf-gcc -Ilib/76b5a35@@igt-xe_xe_gt_c@sta -Ilib -I../lib -I../include -I../include/drm-uapi -I../include/drm-uapi-experimental -I../include/linux-uapi -I../lib/stubs/syscalls -I. -I../ -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libdrm -I/usr/include/libdrm/nouveau -I/usr/include/arm-linux-gnueabihf -I/usr/include/valgrind -I/usr/include/alsa -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O2 -g -D_GNU_SOURCE -include config.h -D_FORTIFY_SOURCE=2 -Wbad-function-cast -Wdeclaration-after-statement -Wformat=2 -Wimplicit-fallthrough=0 -Wlogical-op -Wmissing-declarations -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wuninitialized -Wunused -Wno-clobbered -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-pointer-arith -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter -Wno-unused-result -Werror=address -Werror=array-bounds -Werror=implicit -Werror=init-self -Werror=int-conversion -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=nonnull -Werror=pointer-to-int-cast -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=write-strings -fno-builtin-malloc -fno-builtin-calloc -D_LARGEFILE64_SOURCE=1 -fPIC -pthread '-DIGT_DATADIR="/usr/local/share/igt-gpu-tools"' '-DIGT_SRCDIR="/builds/gfx-ci/igt-ci-tags/tests"' '-DIGT_LOG_DOMAIN="xe/xe_gt"' -MD -MQ 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -MF 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o.d' -o 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -c ../lib/xe/xe_gt.c ../lib/xe/xe_gt.c: In function ‘xe_gt_stats_get_count’:
../lib/xe/xe_gt.c:176:8: error: passing argument 1 of ‘close’ makes integer from pointer without a cast [-Werror=int-conversion]
close(f);
^
In file included from ../lib/igt_core.h:46,
from ../lib/xe/xe_gt.c:12:
/usr/arm-linux-gnueabihf/include/unistd.h:353:23: note: expected ‘int’ but argument is of type ‘FILE *’ {aka ‘struct _IO_FILE *’}
extern int close (int __fd);
~~~~^~~~ cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed. section_end:1733340596:step_script section_start:1733340596:cleanup_file_variables Cleaning up project directory and file based variables section_end:1733340597:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-debian-meson-mips has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/67728245):
[6/1284] Compiling C object 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o'.
FAILED: lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o
/usr/bin/mips-linux-gnu-gcc -Ilib/76b5a35@@igt-xe_xe_gt_c@sta -Ilib -I../lib -I../include -I../include/drm-uapi -I../include/drm-uapi-experimental -I../include/linux-uapi -I../lib/stubs/syscalls -I. -I../ -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/mips-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libdrm -I/usr/include/libdrm/nouveau -I/usr/include/mips-linux-gnu -I/usr/include/valgrind -I/usr/include/alsa -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O2 -g -D_GNU_SOURCE -include config.h -D_FORTIFY_SOURCE=2 -Wbad-function-cast -Wdeclaration-after-statement -Wformat=2 -Wimplicit-fallthrough=0 -Wlogical-op -Wmissing-declarations -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wuninitialized -Wunused -Wno-clobbered -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-pointer-arith -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter -Wno-unused-result -Werror=address -Werror=array-bounds -Werror=implicit -Werror=init-self -Werror=int-conversion -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=nonnull -Werror=pointer-to-int-cast -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=write-strings -fno-builtin-malloc -fno-builtin-calloc -D_LARGEFILE64_SOURCE=1 -fPIC -pthread '-DIGT_DATADIR="/usr/local/share/igt-gpu-tools"' '-DIGT_SRCDIR="/builds/gfx-ci/igt-ci-tags/tests"' '-DIGT_LOG_DOMAIN="xe/xe_gt"' -MD -MQ 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -MF 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o.d' -o 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -c ../lib/xe/xe_gt.c ../lib/xe/xe_gt.c: In function ‘xe_gt_stats_get_count’:
../lib/xe/xe_gt.c:176:8: error: passing argument 1 of ‘close’ makes integer from pointer without a cast [-Werror=int-conversion]
close(f);
^
In file included from ../lib/igt_core.h:46,
from ../lib/xe/xe_gt.c:12:
/usr/mips-linux-gnu/include/unistd.h:353:23: note: expected ‘int’ but argument is of type ‘FILE *’ {aka ‘struct _IO_FILE *’}
extern int close (int __fd);
~~~~^~~~ cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed. section_end:1733340624:step_script section_start:1733340624:cleanup_file_variables Cleaning up project directory and file based variables section_end:1733340624:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-debian-minimal has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/67728242):
[8/417] Compiling C object 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o'.
FAILED: lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o
cc -Ilib/76b5a35@@igt-xe_xe_gt_c@sta -Ilib -I../lib -I../include -I../include/drm-uapi -I../include/drm-uapi-experimental -I../include/linux-uapi -I../lib/stubs/syscalls -I. -I../ -I../lib/stubs/libunwind -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/uuid -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libdrm -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O2 -g -D_GNU_SOURCE -include config.h -D_FORTIFY_SOURCE=2 -Wbad-function-cast -Wdeclaration-after-statement -Wformat=2 -Wimplicit-fallthrough=0 -Wlogical-op -Wmissing-declarations -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wuninitialized -Wunused -Wno-clobbered -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-pointer-arith -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter -Wno-unused-result -Werror=address -Werror=array-bounds -Werror=implicit -Werror=init-self -Werror=int-conversion -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=nonnull -Werror=pointer-to-int-cast -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=write-strings -fno-builtin-malloc -fno-builtin-calloc -D_LARGEFILE64_SOURCE=1 -fPIC -pthread '-DIGT_DATADIR="/usr/local/share/igt-gpu-tools"' '-DIGT_SRCDIR="/builds/gfx-ci/igt-ci-tags/tests"' '-DIGT_LOG_DOMAIN="xe/xe_gt"' -MD -MQ 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -MF 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o.d' -o 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -c ../lib/xe/xe_gt.c ../lib/xe/xe_gt.c: In function ‘xe_gt_stats_get_count’:
../lib/xe/xe_gt.c:176:8: error: passing argument 1 of ‘close’ makes integer from pointer without a cast [-Werror=int-conversion]
close(f);
^
In file included from ../lib/igt_core.h:46,
from ../lib/xe/xe_gt.c:12:
/usr/include/unistd.h:353:23: note: expected ‘int’ but argument is of type ‘FILE *’ {aka ‘struct _IO_FILE *’}
extern int close (int __fd);
~~~~^~~~ cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed. section_end:1733340534:step_script section_start:1733340534:cleanup_file_variables Cleaning up project directory and file based variables section_end:1733340536:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-fedora has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/67728236):
cc -Ilib/76b5a35@@igt-xe_xe_gt_c@sta -Ilib -I../lib -I../include -I../include/drm-uapi -I../include/drm-uapi-experimental -I../include/linux-uapi -I../lib/stubs/syscalls -I. -I../ -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libdrm -I/usr/include/libdrm/nouveau -I/usr/include/valgrind -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O2 -g -D_GNU_SOURCE -include config.h -D_FORTIFY_SOURCE=2 -Wbad-function-cast -Wdeclaration-after-statement -Wformat=2 -Wimplicit-fallthrough=0 -Wlogical-op -Wmissing-declarations -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wuninitialized -Wunused -Wno-clobbered -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-pointer-arith -Wno-address-of-packed-member -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter -Wno-unused-result -Werror=address -Werror=array-bounds -Werror=implicit -Werror=init-self -Werror=int-conversion -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=nonnull -Werror=pointer-to-int-cast -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=write-strings -fno-builtin-malloc -fno-builtin-calloc -D_LARGEFILE64_SOURCE=1 -fPIC -pthread '-DIGT_DATADIR="/opt/igt/share/igt-gpu-tools"' '-DIGT_SRCDIR="/builds/gfx-ci/igt-ci-tags/tests"' '-DIGT_LOG_DOMAIN="xe/xe_gt"' -MD -MQ 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -MF 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o.d' -o 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -c ../lib/xe/xe_gt.c ../lib/xe/xe_gt.c: In function ‘xe_gt_stats_get_count’:
../lib/xe/xe_gt.c:176:8: error: passing argument 1 of ‘close’ makes integer from pointer without a cast [-Werror=int-conversion]
176 | close(f);
| ^
| |
| FILE * {aka struct _IO_FILE *}
In file included from ../lib/igt_core.h:46,
from ../lib/xe/xe_gt.c:12:
/usr/include/unistd.h:353:23: note: expected ‘int’ but argument is of type ‘FILE *’ {aka ‘struct _IO_FILE *’}
353 | extern int close (int __fd);
| ~~~~^~~~ cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed. section_end:1733340515:step_script section_start:1733340515:cleanup_file_variables Cleaning up project directory and file based variables section_end:1733340515:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-fedora-clang has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/67728240):
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../lib/xe/xe_gt.c:178:9: note: uninitialized use occurs here
return count;
^~~~~
../lib/xe/xe_gt.c:169:9: note: remove the condition if it is always true
while (fgets(tlb_path, sizeof(tlb_path), f)) {
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1
../lib/xe/xe_gt.c:158:11: note: initialize the variable 'count' to silence this warning
int count;
^
= 0 1 warning and 1 error generated.
ninja: build stopped: subcommand failed. section_end:1733340518:step_script section_start:1733340518:cleanup_file_variables Cleaning up project directory and file based variables section_end:1733340518:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-fedora-no-libdrm-nouveau has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/67728239):
cc -Ilib/76b5a35@@igt-xe_xe_gt_c@sta -Ilib -I../lib -I../include -I../include/drm-uapi -I../include/drm-uapi-experimental -I../include/linux-uapi -I../lib/stubs/syscalls -I. -I../ -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libdrm -I/usr/include/valgrind -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O2 -g -D_GNU_SOURCE -include config.h -D_FORTIFY_SOURCE=2 -Wbad-function-cast -Wdeclaration-after-statement -Wformat=2 -Wimplicit-fallthrough=0 -Wlogical-op -Wmissing-declarations -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wuninitialized -Wunused -Wno-clobbered -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-pointer-arith -Wno-address-of-packed-member -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter -Wno-unused-result -Werror=address -Werror=array-bounds -Werror=implicit -Werror=init-self -Werror=int-conversion -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=nonnull -Werror=pointer-to-int-cast -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=write-strings -fno-builtin-malloc -fno-builtin-calloc -D_LARGEFILE64_SOURCE=1 -fPIC -pthread '-DIGT_DATADIR="/usr/local/share/igt-gpu-tools"' '-DIGT_SRCDIR="/builds/gfx-ci/igt-ci-tags/tests"' '-DIGT_LOG_DOMAIN="xe/xe_gt"' -MD -MQ 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -MF 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o.d' -o 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -c ../lib/xe/xe_gt.c ../lib/xe/xe_gt.c: In function ‘xe_gt_stats_get_count’:
../lib/xe/xe_gt.c:176:8: error: passing argument 1 of ‘close’ makes integer from pointer without a cast [-Werror=int-conversion]
176 | close(f);
| ^
| |
| FILE * {aka struct _IO_FILE *}
In file included from ../lib/igt_core.h:46,
from ../lib/xe/xe_gt.c:12:
/usr/include/unistd.h:353:23: note: expected ‘int’ but argument is of type ‘FILE *’ {aka ‘struct _IO_FILE *’}
353 | extern int close (int __fd);
| ~~~~^~~~ cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed. section_end:1733340534:step_script section_start:1733340534:cleanup_file_variables Cleaning up project directory and file based variables section_end:1733340536:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-fedora-no-libunwind has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/67728237):
cc -Ilib/76b5a35@@igt-xe_xe_gt_c@sta -Ilib -I../lib -I../include -I../include/drm-uapi -I../include/drm-uapi-experimental -I../include/linux-uapi -I../lib/stubs/syscalls -I. -I../ -I../lib/stubs/libunwind -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libdrm -I/usr/include/libdrm/nouveau -I/usr/include/valgrind -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O2 -g -D_GNU_SOURCE -include config.h -D_FORTIFY_SOURCE=2 -Wbad-function-cast -Wdeclaration-after-statement -Wformat=2 -Wimplicit-fallthrough=0 -Wlogical-op -Wmissing-declarations -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wuninitialized -Wunused -Wno-clobbered -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-pointer-arith -Wno-address-of-packed-member -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter -Wno-unused-result -Werror=address -Werror=array-bounds -Werror=implicit -Werror=init-self -Werror=int-conversion -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=nonnull -Werror=pointer-to-int-cast -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=write-strings -fno-builtin-malloc -fno-builtin-calloc -D_LARGEFILE64_SOURCE=1 -fPIC -pthread '-DIGT_DATADIR="/usr/local/share/igt-gpu-tools"' '-DIGT_SRCDIR="/builds/gfx-ci/igt-ci-tags/tests"' '-DIGT_LOG_DOMAIN="xe/xe_gt"' -MD -MQ 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -MF 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o.d' -o 'lib/76b5a35@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -c ../lib/xe/xe_gt.c ../lib/xe/xe_gt.c: In function ‘xe_gt_stats_get_count’:
../lib/xe/xe_gt.c:176:8: error: passing argument 1 of ‘close’ makes integer from pointer without a cast [-Werror=int-conversion]
176 | close(f);
| ^
| |
| FILE * {aka struct _IO_FILE *}
In file included from ../lib/igt_core.h:46,
from ../lib/xe/xe_gt.c:12:
/usr/include/unistd.h:353:23: note: expected ‘int’ but argument is of type ‘FILE *’ {aka ‘struct _IO_FILE *’}
353 | extern int close (int __fd);
| ~~~~^~~~ cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed. section_end:1733340534:step_script section_start:1733340534:cleanup_file_variables Cleaning up project directory and file based variables section_end:1733340536:cleanup_file_variables
ERROR: Job failed: exit code 1
build:tests-fedora-oldest-meson has failed (https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/jobs/67728238):
cc -Ilib/lib@@igt-xe_xe_gt_c@sta -Ilib -I../lib -I../include -I../include/drm-uapi -I../include/drm-uapi-experimental -I../include/linux-uapi -I../lib/stubs/syscalls -I. -I../ -I/usr/include/cairo -I/usr/include/glib-2.0 -I/usr/lib64/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libdrm -I/usr/include/libdrm/nouveau -I/usr/include/valgrind -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O2 -g -D_GNU_SOURCE -include config.h -D_FORTIFY_SOURCE=2 -Wbad-function-cast -Wdeclaration-after-statement -Wformat=2 -Wimplicit-fallthrough=0 -Wlogical-op -Wmissing-declarations -Wmissing-format-attribute -Wmissing-noreturn -Wmissing-prototypes -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-prototypes -Wuninitialized -Wunused -Wno-clobbered -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-pointer-arith -Wno-address-of-packed-member -Wno-sign-compare -Wno-type-limits -Wno-unused-parameter -Wno-unused-result -Werror=address -Werror=array-bounds -Werror=implicit -Werror=init-self -Werror=int-conversion -Werror=int-to-pointer-cast -Werror=main -Werror=missing-braces -Werror=nonnull -Werror=pointer-to-int-cast -Werror=return-type -Werror=sequence-point -Werror=trigraphs -Werror=write-strings -fno-builtin-malloc -fno-builtin-calloc -D_LARGEFILE64_SOURCE=1 -fPIC -pthread '-DIGT_DATADIR="/usr/local/share/igt-gpu-tools"' '-DIGT_SRCDIR="/builds/gfx-ci/igt-ci-tags/tests"' '-DIGT_LOG_DOMAIN="xe/xe_gt"' -MD -MQ 'lib/lib@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -MF 'lib/lib@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o.d' -o 'lib/lib@@igt-xe_xe_gt_c@sta/xe_xe_gt.c.o' -c ../lib/xe/xe_gt.c ../lib/xe/xe_gt.c: In function ‘xe_gt_stats_get_count’:
../lib/xe/xe_gt.c:176:8: error: passing argument 1 of ‘close’ makes integer from pointer without a cast [-Werror=int-conversion]
176 | close(f);
| ^
| |
| FILE * {aka struct _IO_FILE *}
In file included from ../lib/igt_core.h:46,
from ../lib/xe/xe_gt.c:12:
/usr/include/unistd.h:353:23: note: expected ‘int’ but argument is of type ‘FILE *’ {aka ‘struct _IO_FILE *’}
353 | extern int close (int __fd);
| ~~~~^~~~ cc1: some warnings being treated as errors
ninja: build stopped: subcommand failed. section_end:1733340513:step_script section_start:1733340513:cleanup_file_variables Cleaning up project directory and file based variables section_end:1733340513:cleanup_file_variables
ERROR: Job failed: exit code 1
== Logs ==
For more details see: https://gitlab.freedesktop.org/gfx-ci/igt-ci-tags/-/pipelines/1323511
Hi Jonathan,
Quoted 42 lines · Jonathan Cavitt
Resolve the following issues:
- The target directory for the fopen does not take into consideration the dri subdirectory and assumes the correct path is dri/0. This might not be the case. Use the "minor" function and fstat to generate the correct subdirectory.
- The fopen may fail and return a NULL pointer, causing the subsequent fgets to generate a SIGSEGV. Assert the file opened correctly.
- The file opened by fopen is never closed. Close it.
Fixes 10cefd82 ("tests/intel/xe_tlb: Add test to check TLB invalidation")Signed-off-by Jonathan Cavitt <[email protected]>Suggested-by Kamil Konieczny <[email protected]>CC Sai Gowtham Ch <[email protected]>--- lib/xe/xe_gt.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)lib/xe/xe_gt.c +6
-1@@ -152,18 +152,28 @@ void xe_post_hang_ring(int fd, igt_hang_t arg)int xe_gt_stats_get_count (int fd,int gt,const char *stat) {FILE *f; +struct stat st;char tlb_path[4096 ];char path[256 ];int count; -sprintf (path,"/sys/kernel/debug/dri/0/gt%d/stats" , gt); +igt_assert_eq (fstat (fd, &st),0 ); + +sprintf (path,"/sys/kernel/debug/dri/%d/gt%d/stats" , +minor (st.st_rdev), gt); f =fopen (path,"r" ); + igt_assert_f(f, "Failed to open /sys/kernel/debug/dri/%d/gt%d/stats",
lib/xe/xe_gt.c void xe_post_hang_ring(int fd, igt_hang_t arg) · line 176
Quoted 10 lines
lib/xe/xe_gt.c +4
-0+ minor(st.st_rdev), gt); +while (fgets (tlb_path,sizeof (tlb_path), f)) {if (strstr (tlb_path, stat) !=NULL ) {sscanf (tlb_path,"%*[^:]: %d" , &count);break ; } } + +close (f);
I missed this, it should be fclose()
My r-b still holds,
Regards,
Kamil
Quoted 6 lines
lib/xe/xe_gt.c +1
-0+return count; }Signature · 1 line
2.43.0