libpayload: Add strerror
Change-Id: I33d45ad7d09473b8c6f5b7ee5fbadc0d184f9dcd Signed-off-by: Stefan Tauner <stefan.tauner@gmx.at> Reviewed-on: http://review.coreboot.org/3537 Tested-by: build bot (Jenkins) Reviewed-by: Nico Huber <nico.huber@secunet.com>
This commit is contained in:
		
				
					committed by
					
						
						Nico Huber
					
				
			
			
				
	
			
			
			
						parent
						
							c0b1a48cda
						
					
				
				
					commit
					c9246da4dd
				
			@@ -63,8 +63,9 @@ char *strstr(const char *h, const char *n);
 | 
			
		||||
char *strsep(char **stringp, const char *delim);
 | 
			
		||||
size_t strspn(const char *s, const char *a);
 | 
			
		||||
size_t strcspn(const char *s, const char *a);
 | 
			
		||||
char* strtok(char *str, const char *delim);
 | 
			
		||||
char* strtok_r(char *str, const char *delim, char **ptr);
 | 
			
		||||
char *strtok(char *str, const char *delim);
 | 
			
		||||
char *strtok_r(char *str, const char *delim, char **ptr);
 | 
			
		||||
char *strerror(int errnum);
 | 
			
		||||
/** @} */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 
 | 
			
		||||
@@ -639,3 +639,17 @@ void perror(const char *s)
 | 
			
		||||
{
 | 
			
		||||
	printf("%s: %d\n", s?s:"(none)", errno);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Get a message string describing the given error number.
 | 
			
		||||
 *
 | 
			
		||||
 * @param errnum The error number to be interpreted
 | 
			
		||||
 * @return A pointer to a string describing the given error number
 | 
			
		||||
 */
 | 
			
		||||
char *strerror(int errnum)
 | 
			
		||||
{
 | 
			
		||||
	/* Reserve enough space for the string below + INT64_MIN in decimal + \0 */
 | 
			
		||||
	static char errstr[35];
 | 
			
		||||
	snprintf(errstr, sizeof(errstr), "Unknown error %d", errnum);
 | 
			
		||||
	return errstr;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user