mirror of
				https://github.com/asterisk/asterisk.git
				synced 2025-10-31 02:37:10 +00:00 
			
		
		
		
	Fix build warnings related to printf/scanf of tv_usec.
The type of tv_usec is suseconds_t. On Linux, this is usually a long int, but the specification is actually pretty lax on what it might actually be. And, sadly, there's no printf/scanf width specifier for suseconds_t. So it could bit an int or a long, but there's not a great way to tell which it is. This patch fixes scanf by reading into a long temporary variable that's then stored into the tv_usec. It fixes printf by casting the tv_usec to a long first. This patch also adds some missing width specifiers for some debug statements, which would cause ".000001" to be displayed at ".1". git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@392076 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
		| @@ -248,11 +248,14 @@ static int cdr_read(struct ast_channel *chan, const char *cmd, char *parse, | ||||
| 				|| !strcasecmp("answer", args.variable)) { | ||||
| 			struct timeval fmt_time; | ||||
| 			struct ast_tm tm; | ||||
| 			if (sscanf(tempbuf, "%ld.%ld", &fmt_time.tv_sec, &fmt_time.tv_usec) != 2) { | ||||
| 			/* tv_usec is suseconds_t, which could be int or long */ | ||||
| 			long int tv_usec; | ||||
| 			if (sscanf(tempbuf, "%ld.%ld", &fmt_time.tv_sec, &tv_usec) != 2) { | ||||
| 				ast_log(AST_LOG_WARNING, "Unable to parse %s (%s) from the CDR for channel %s\n", | ||||
| 						args.variable, tempbuf, ast_channel_name(chan)); | ||||
| 				return 0; | ||||
| 			} | ||||
| 			fmt_time.tv_usec = tv_usec; | ||||
| 			ast_localtime(&fmt_time, &tm, NULL); | ||||
| 			ast_strftime(tempbuf, sizeof(*tempbuf), "%Y-%m-%d %T", &tm); | ||||
| 		} else if (!strcasecmp("disposition", args.variable)) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user