mirror of
				https://git.proxmox.com/git/mirror_zfs
				synced 2025-11-04 03:24:44 +00:00 
			
		
		
		
	libspl: print_timestamp: use localtime_r()
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #13284
This commit is contained in:
		
							parent
							
								
									8ab279484f
								
							
						
					
					
						commit
						ae3683ce11
					
				@ -44,7 +44,7 @@ void
 | 
			
		||||
print_timestamp(uint_t timestamp_fmt)
 | 
			
		||||
{
 | 
			
		||||
	time_t t = time(NULL);
 | 
			
		||||
	static char *fmt = NULL;
 | 
			
		||||
	static const char *fmt = NULL;
 | 
			
		||||
 | 
			
		||||
	/* We only need to retrieve this once per invocation */
 | 
			
		||||
	if (fmt == NULL)
 | 
			
		||||
@ -54,9 +54,10 @@ print_timestamp(uint_t timestamp_fmt)
 | 
			
		||||
		(void) printf("%lld\n", (longlong_t)t);
 | 
			
		||||
	} else if (timestamp_fmt == DDATE) {
 | 
			
		||||
		char dstr[64];
 | 
			
		||||
		struct tm tm;
 | 
			
		||||
		int len;
 | 
			
		||||
 | 
			
		||||
		len = strftime(dstr, sizeof (dstr), fmt, localtime(&t));
 | 
			
		||||
		len = strftime(dstr, sizeof (dstr), fmt, localtime_r(&t, &tm));
 | 
			
		||||
		if (len > 0)
 | 
			
		||||
			(void) printf("%s\n", dstr);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user