1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-20 16:56:10 +02:00
git/compat/hstrerror.c
Jeff King 48bdf86995 compat/hstrerror: convert sprintf to snprintf
This is a trivially correct use of sprintf, as our error
number should not be excessively long. But it's still nice
to drop an sprintf call.

Note that we cannot use xsnprintf here, because this is
compat code which does not load git-compat-util.h.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-09-25 10:18:18 -07:00

22 lines
530 B
C

#include <string.h>
#include <stdio.h>
#include <netdb.h>
const char *githstrerror(int err)
{
static char buffer[48];
switch (err)
{
case HOST_NOT_FOUND:
return "Authoritative answer: host not found";
case NO_DATA:
return "Valid name, no data record of requested type";
case NO_RECOVERY:
return "Non recoverable errors, FORMERR, REFUSED, NOTIMP";
case TRY_AGAIN:
return "Non-authoritative \"host not found\", or SERVERFAIL";
}
snprintf(buffer, sizeof(buffer), "Name resolution error %d", err);
return buffer;
}