i-g-t: fix compile warnings
cover i-g-t: fix compile warnings
These are harmless apart from ignoring eventual errors, but they make it difficult to spot new errors/warnings in the build output.
Imre Deak (8):
fix warn: 'div' shadows a global declaration
fix warn in intel_error_decode: ignoring return value of 'asprintf' fix warn in intel_reg_snapshot: ignoring return value of 'write' fix warn in gem_readwrite: 'read/write' shadows a global declaration fix warn in sysfs_{rc6,rps}*: ignoring return value of 'fscanf' fix warn in gem_reg_read: 'read' shadows a global declaration fix warn in prime_nv_*: ignoring return value of ‘fgets’ fix warn in testdisplay: ignoring return value of 'chdir'
lib/drmtest.c | 6 +++--- tests/gem_readwrite.c | 28 ++++++++++++++-------------- tests/gem_reg_read.c | 18 +++++++++--------- tests/gem_storedw_batches_loop.c | 6 +++--- tests/gem_storedw_loop_blt.c | 6 +++--- tests/gem_storedw_loop_bsd.c | 6 +++--- tests/gem_storedw_loop_render.c | 6 +++--- tests/prime_nv_api.c | 5 ++++- tests/prime_nv_test.c | 5 ++++- tests/sysfs_rc6_residency.c | 5 ++++- tests/sysfs_rps.c | 6 +++++- tests/testdisplay.c | 4 +++- tools/intel_error_decode.c | 10 ++++++++-- tools/intel_reg_snapshot.c | 5 ++++- 14 files changed, 70 insertions(+), 46 deletions(-)
Signature · 6 lines
1.7.9.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/8 fix warn: 'div' shadows a global declaration
--- lib/drmtest.c | 6 +++--- tests/gem_storedw_batches_loop.c | 6 +++--- tests/gem_storedw_loop_blt.c | 6 +++--- tests/gem_storedw_loop_bsd.c | 6 +++--- tests/gem_storedw_loop_render.c | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-)
lib/drmtest.c +3 -3
@@ -541,7 +541,7 @@ void drmtest_permute_array(void *array, unsigned size,void drmtest_progress (const char *header,uint64_t i,uint64_t total) { -int div =200 ; +int divider =200 ;if (i+1 >= total) {fprintf (stderr,"\r%s100%%\n" , header);
@@ -549,10 +549,10 @@ void drmtest_progress(const char *header, uint64_t i, uint64_t total) }if (total /200 ==0 ) - div =1 ; + divider =1 ;/* only bother updating about every 0.5% */ -if (i % (total / div) ==0 || i+1 >= total) { +if (i % (total / divider) ==0 || i+1 >= total) {fprintf (stderr,"\r%s%3llu%%" , header, (long long unsigned ) i *100 / total); }
tests/gem_storedw_batches_loop.c +3 -3
@@ -48,13 +48,13 @@ static int has_ppgtt = 0;/* Like the store dword test, but we create new command buffers each time */ static void -store_dword_loop (int div) +store_dword_loop (int divider) {int cmd, i, val =0 , ret;uint32_t *buf;drm_intel_bo *cmd_bo; -printf ("running storedw loop with stall every %i batch\n" , div); +printf ("running storedw loop with stall every %i batch\n" , divider); cmd =MI_STORE_DWORD_IMM ;if (!has_ppgtt)
@@ -106,7 +106,7 @@ store_dword_loop(int div)exit (-1 ); } -if (i % div !=0 ) +if (i % divider !=0 ) goto cont;drm_intel_bo_wait_rendering (cmd_bo);
tests/gem_storedw_loop_blt.c +3 -3
@@ -52,12 +52,12 @@ static int has_ppgtt = 0;*/ static void -store_dword_loop (int div) +store_dword_loop (int divider) {int cmd, i, val =0 ;uint32_t *buf; -printf ("running storedw loop on blt with stall every %i batch\n" , div); +printf ("running storedw loop on blt with stall every %i batch\n" , divider); cmd =MI_STORE_DWORD_IMM ;if (!has_ppgtt)
@@ -74,7 +74,7 @@ store_dword_loop(int div)intel_batchbuffer_flush_on_ring (batch,I915_EXEC_BLT ); -if (i % div !=0 ) +if (i % divider !=0 ) goto cont;drm_intel_bo_map (target_buffer,0 );
tests/gem_storedw_loop_bsd.c +3 -3
@@ -52,12 +52,12 @@ static int has_ppgtt = 0;*/ static void -store_dword_loop (int div) +store_dword_loop (int divider) {int cmd, i, val =0 ;uint32_t *buf; -printf ("running storedw loop on bsd with stall every %i batch\n" , div); +printf ("running storedw loop on bsd with stall every %i batch\n" , divider); cmd =MI_STORE_DWORD_IMM ;if (!has_ppgtt)
@@ -74,7 +74,7 @@ store_dword_loop(int div)intel_batchbuffer_flush_on_ring (batch,I915_EXEC_BSD ); -if (i % div !=0 ) +if (i % divider !=0 ) goto cont;drm_intel_bo_map (target_buffer,0 );
tests/gem_storedw_loop_render.c +3 -3
@@ -52,12 +52,12 @@ static int has_ppgtt = 0;*/ static void -store_dword_loop (int div) +store_dword_loop (int divider) {int cmd, i, val =0 ;uint32_t *buf; -printf ("running storedw loop on render with stall every %i batch\n" , div); +printf ("running storedw loop on render with stall every %i batch\n" , divider); cmd =MI_STORE_DWORD_IMM ;if (!has_ppgtt)
@@ -74,7 +74,7 @@ store_dword_loop(int div)intel_batchbuffer_flush_on_ring (batch,0 ); -if (i % div !=0 ) +if (i % divider !=0 ) goto cont;drm_intel_bo_map (target_buffer,0 );
Signature · 1 line
1.7.9.5
PATCH 2/8 fix warn in intel_error_decode: ignoring return value of 'asprintf'
In reply to Imre Deak--- tools/intel_error_decode.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
tools/intel_error_decode.c +8 -2
@@ -49,6 +49,7 @@#include <errno.h> #include <sys/stat.h> #include <err.h> +#include <assert.h> #include <intel_bufmgr.h> #include "intel_chipset.h"
@@ -479,13 +480,18 @@ main (int argc, char *argv[]) }if (S_ISDIR (st.st_mode)) { -asprintf (&filename,"%s/i915_error_state" , path); +int ret; + + ret =asprintf (&filename,"%s/i915_error_state" , path); +assert (ret >0 ); file =fopen (filename,"r" );if (!file) {int minor;for (minor =0 ; minor <64 ; minor++) {free (filename); -asprintf (&filename,"%s/%d/i915_error_state" , path, minor); + ret =asprintf (&filename,"%s/%d/i915_error_state" , path, minor); +assert (ret >0 ); + file =fopen (filename,"r" );if (file)break ;
Signature · 1 line
1.7.9.5
PATCH 3/8 fix warn in intel_reg_snapshot: ignoring return value of 'write'
In reply to Imre Deak--- tools/intel_reg_snapshot.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/intel_reg_snapshot.c +4 -1
@@ -25,6 +25,7 @@*/ #include <unistd.h> +#include <assert.h> #include "intel_gpu_tools.h" int main (int argc,char ** argv)
@@ -32,6 +33,7 @@ int main(int argc, char** argv)struct pci_device *pci_dev;uint32_t devid;int mmio_bar; +int ret; pci_dev =intel_get_pci_device (); devid = pci_dev->device_id;
@@ -42,7 +44,8 @@ int main(int argc, char** argv)else mmio_bar =0 ; -write (1 , mmio, pci_dev->regions[mmio_bar].size); + ret =write (1 , mmio, pci_dev->regions[mmio_bar].size); +assert (ret >0 );return 0 ; }
Signature · 1 line
1.7.9.5
PATCH 4/8 fix warn in gem_readwrite: 'read/write' shadows a global declaration
In reply to Imre Deak--- tests/gem_readwrite.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
tests/gem_readwrite.c +14 -14
@@ -44,34 +44,34 @@static int do_read (int fd,int handle,void *buf,int offset,int size) { -struct drm_i915_gem_pread read; +struct drm_i915_gem_pread gem_pread;/* Ensure that we don't have any convenient data in buf in case * we fail. */ memset (buf,0xd0 , size); -memset (&read,0 ,sizeof (read)); - read.handle = handle; - read.data_ptr = (uintptr_t )buf; - read.size = size; - read.offset = offset; +memset (&gem_pread,0 ,sizeof (gem_pread)); + gem_pread.handle = handle; + gem_pread.data_ptr = (uintptr_t )buf; + gem_pread.size = size; + gem_pread.offset = offset; -return ioctl (fd,DRM_IOCTL_I915_GEM_PREAD , &read); +return ioctl (fd,DRM_IOCTL_I915_GEM_PREAD , &gem_pread); }static int do_write (int fd,int handle,void *buf,int offset,int size) { -struct drm_i915_gem_pwrite write; +struct drm_i915_gem_pwrite gem_pwrite; -memset (&write,0 ,sizeof (write)); - write.handle = handle; - write.data_ptr = (uintptr_t )buf; - write.size = size; - write.offset = offset; +memset (&gem_pwrite,0 ,sizeof (gem_pwrite)); + gem_pwrite.handle = handle; + gem_pwrite.data_ptr = (uintptr_t )buf; + gem_pwrite.size = size; + gem_pwrite.offset = offset; -return ioctl (fd,DRM_IOCTL_I915_GEM_PWRITE , &write); +return ioctl (fd,DRM_IOCTL_I915_GEM_PWRITE , &gem_pwrite); }int main (int argc,char **argv)
Signature · 1 line
1.7.9.5
PATCH 5/8 fix warn in sysfs_{rc6, rps}*: ignoring return value of 'fscanf'
In reply to Imre Deak--- tests/sysfs_rc6_residency.c | 5 ++++- tests/sysfs_rps.c | 6 +++++- 2 files changed, 9 insertions(+), 2 deletions(-)
tests/sysfs_rc6_residency.c +4 -1
@@ -38,6 +38,7 @@static unsigned int readit (const char *path) {unsigned int ret; +int scanned;FILE *file; file =fopen (path,"r" );
@@ -45,7 +46,9 @@ static unsigned int readit(const char *path)fprintf (stderr,"Couldn't open %s (%d)\n" , path, errno);abort (); } -fscanf (file,"%u" , &ret); + scanned =fscanf (file,"%u" , &ret); +assert (scanned ==1 ); +fclose (file);return ret;
tests/sysfs_rps.c +5 -1
@@ -64,9 +64,13 @@ struct junk {static int readval (FILE *filp) {int val; +int scanned; +fflush (filp);rewind (filp); -fscanf (filp,"%d" , &val); + scanned =fscanf (filp,"%d" , &val); +assert (scanned ==1 ); +return val; }
Signature · 1 line
1.7.9.5
PATCH 6/8 fix warn in gem_reg_read: 'read' shadows a global declaration
In reply to Imre Deak--- tests/gem_reg_read.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
tests/gem_reg_read.c +9 -9
@@ -52,29 +52,29 @@ static void handle_bad(int ret, int lerrno, int expected, const char *desc)static uint64_t timer_query (int fd) { -struct local_drm_i915_reg_read read; +struct local_drm_i915_reg_read reg_read;int ret; - read.offset =0x2358 ; - ret =drmIoctl (fd,REG_READ_IOCTL , &read); + reg_read.offset =0x2358 ; + ret =drmIoctl (fd,REG_READ_IOCTL , ®_read);if (ret) {perror ("positive test case failed: " );exit (EXIT_FAILURE ); } -return read.val; +return reg_read.val; }int main (int argc,char *argv[]) { -struct local_drm_i915_reg_read read; +struct local_drm_i915_reg_read reg_read;int ret, fd;uint64_t val; fd =drm_open_any (); - read.offset =0x2358 ; - ret =drmIoctl (fd,REG_READ_IOCTL , &read); + reg_read.offset =0x2358 ; + ret =drmIoctl (fd,REG_READ_IOCTL , ®_read);if (errno ==EINVAL )exit (77 );else if (ret)
@@ -88,8 +88,8 @@ int main(int argc, char *argv[]) }/* bad reg */ - read.offset =0x12345678 ; - ret =drmIoctl (fd,REG_READ_IOCTL , &read); + reg_read.offset =0x12345678 ; + ret =drmIoctl (fd,REG_READ_IOCTL , ®_read);handle_bad (ret, errno,EINVAL ,"bad register" );close (fd);
Signature · 1 line
1.7.9.5
PATCH 7/8 fix warn in prime_nv_*: ignoring return value of ‘fgets’
In reply to Imre Deak--- tests/prime_nv_api.c | 5 ++++- tests/prime_nv_test.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-)
tests/prime_nv_api.c +4 -1
@@ -38,6 +38,8 @@ static int find_and_open_devices(void)char vendor_id[8 ];int venid;for (i =0 ; i <9 ; i++) { +char *ret; +sprintf (path,"/sys/class/drm/card%d/device/vendor" , i);if (stat (path, &buf))break ;
@@ -46,7 +48,8 @@ static int find_and_open_devices(void)if (!fl)break ; -fgets (vendor_id,8 , fl); + ret =fgets (vendor_id,8 , fl); +assert (ret);fclose (fl); venid =strtoul (vendor_id,NULL ,16 );
tests/prime_nv_test.c +4 -1
@@ -46,6 +46,8 @@ static int find_and_open_devices(void)char vendor_id[8 ];int venid;for (i =0 ; i <9 ; i++) { +char *ret; +sprintf (path,"/sys/class/drm/card%d/device/vendor" , i);if (stat (path, &buf))break ;
@@ -54,7 +56,8 @@ static int find_and_open_devices(void)if (!fl)break ; -fgets (vendor_id,8 , fl); + ret =fgets (vendor_id,8 , fl); +assert (ret);fclose (fl); venid =strtoul (vendor_id,NULL ,16 );
Signature · 1 line
1.7.9.5
PATCH 8/8 fix warn in testdisplay: ignoring return value of 'chdir'
In reply to Imre Deak--- tests/testdisplay.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tests/testdisplay.c +3 -1
@@ -647,6 +647,7 @@ static void enter_exec_path( char **argv )char *exec_path =NULL ;char *pos =NULL ;short len_path =0 ; +int ret; len_path =strlen ( argv[0 ] ); exec_path = (char *)malloc (len_path);
@@ -656,7 +657,8 @@ static void enter_exec_path( char **argv )if (pos !=NULL ) *(pos+1 ) ='\0' ; -chdir (exec_path); + ret =chdir (exec_path); +assert (ret ==0 );free (exec_path); }
Signature · 1 line
1.7.9.5