Use function format attribute where applicable
Allow the compiler to verify the format string against the supplied
arguments.
    chage.c:239:51: warning: format not a string literal, format string not checked [-Wformat-nonliteral]
      239 |                 (void) strftime (buf, sizeof buf, format, tp);
          |                                                   ^~~~~~
			
			
This commit is contained in:
		
				
					committed by
					
						
						Serge Hallyn
					
				
			
			
				
	
			
			
			
						parent
						
							477c8e6f42
						
					
				
				
					commit
					c6c8130db4
				
			
							
								
								
									
										10
									
								
								src/chage.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/chage.c
									
									
									
									
									
								
							@@ -223,20 +223,12 @@ static void print_date (time_t date)
 | 
			
		||||
{
 | 
			
		||||
	struct tm *tp;
 | 
			
		||||
	char buf[80];
 | 
			
		||||
	char format[80];
 | 
			
		||||
 | 
			
		||||
	if (iflg) {
 | 
			
		||||
		(void) snprintf (format, 80, "%%Y-%%m-%%d");
 | 
			
		||||
	}
 | 
			
		||||
	else {
 | 
			
		||||
		(void) snprintf (format, 80, "%%b %%d, %%Y");
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	tp = gmtime (&date);
 | 
			
		||||
	if (NULL == tp) {
 | 
			
		||||
		(void) printf ("time_t: %lu\n", (unsigned long)date);
 | 
			
		||||
	} else {
 | 
			
		||||
		(void) strftime (buf, sizeof buf, format, tp);
 | 
			
		||||
		(void) strftime (buf, sizeof buf, iflg ? "%%Y-%%m-%%d" : "%%b %%d, %%Y", tp);
 | 
			
		||||
		(void) puts (buf);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user