[igt-dev] [PATCH i-g-t 4/6] lib/igt_device_scan: Align microseconds to six leading zeros

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Tue Jul 12 08:12:37 UTC 2022


On Mon, Jul 11, 2022 at 01:33:42PM +0200, Kamil Konieczny wrote:
> On 2022-07-07 at 08:59:37 +0200, Zbigniew Kempczyński wrote:
> > Previous format was not correct when DBG() was in use leading to
> > not properly aligned output.
> > 
> > Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
> > ---
> >  lib/igt_device_scan.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c
> > index afb6f07e18..e41c9f8b64 100644
> > --- a/lib/igt_device_scan.c
> > +++ b/lib/igt_device_scan.c
> > @@ -34,6 +34,7 @@
> >  #include <libudev.h>
> >  #include <linux/limits.h>
> >  #include <sys/stat.h>
> > +#include <sys/time.h>
> >  #include <sys/types.h>
> >  
> >  /**
> > @@ -170,7 +171,7 @@
> >  { \
> >  	struct timeval tm; \
> >  	gettimeofday(&tm, NULL); \
> > -	printf("%10ld.%03ld: ", tm.tv_sec, tm.tv_usec); \
> > +	printf("%10ld.%06ld: ", tm.tv_sec, tm.tv_usec); \
> ---------------- ^
> I checked other debug prints and this is the only place which
> uses 10ld for seconds, in other places there is %ld, so maybe
> it is worth to change this ?

I've enforced alignment to 10 digit to be sure time it will be 
well formatted even if on test machine date would be 1970 (I got 
this in my mind from the past). We will switch to 11ld in 2286-11-20
so if nothing amazing will happen I likely won't see this jump
in the future.

If you want I will change this - this code is blocked anyway unless
you're playing with debug.

--
Zbigniew 

> 
> Reviewed-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
> 
> >  	printf(__VA_ARGS__); \
> >  }
> >  
> > -- 
> > 2.34.1
> > 


More information about the igt-dev mailing list