X-Git-Url: https://git.ozlabs.org/?p=petitboot;a=blobdiff_plain;f=lib%2Futil%2Futil.c;h=a18926c1ac74c9446629d0ad01199db467c9d449;hp=75b1c23620176ff4ded978ae15c362a831cc8443;hb=3f06f8808f79f13650394bab80bf96426323a5f8;hpb=072847109936bc0e822f8cf67c31eb62183f0db8 diff --git a/lib/util/util.c b/lib/util/util.c index 75b1c23..a18926c 100644 --- a/lib/util/util.c +++ b/lib/util/util.c @@ -15,12 +15,14 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#include #include #include #include +static const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', }; + void mac_str(uint8_t *mac, unsigned int maclen, char *buf, unsigned int buflen) { unsigned int i; @@ -36,8 +38,9 @@ void mac_str(uint8_t *mac, unsigned int maclen, char *buf, unsigned int buflen) pos = buf; for (i = 0; i < maclen; i++) { - snprintf(pos, 4, "%02x:", mac[i]); - pos += 3; + *(pos++) = hex[mac[i] >> 4 & 0xf]; + *(pos++) = hex[mac[i] & 0xf]; + *(pos++) = ':'; } *(pos - 1) = '\0';