From 19eecef2f9d98622e71c7a8f397807a6367c5333 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 23 Jul 2007 23:55:37 +0200 Subject: [PATCH] fdisk: cleanup partname.c Signed-off-by: Karel Zak --- fdisk/partname.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/fdisk/partname.c b/fdisk/partname.c index 0ae058f9..8f60b718 100644 --- a/fdisk/partname.c +++ b/fdisk/partname.c @@ -6,17 +6,12 @@ /* * return partition name - uses static storage unless buf is supplied */ -static char * -partnamebf(char *dev, int pno, int lth, int bufsiz, char *bufp) { - static char buffer[80]; +char * +partname(char *dev, int pno, int lth) { + static char bufp[80]; char *p; int w, wp; - if (!bufp) { - bufp = buffer; - bufsiz = sizeof(buffer); - } - w = strlen(dev); p = ""; @@ -38,17 +33,13 @@ partnamebf(char *dev, int pno, int lth, int bufsiz, char *bufp) { } wp = strlen(p); - + if (lth) { - snprintf(bufp, bufsiz, "%*.*s%s%-2u", + snprintf(bufp, sizeof(bufp), "%*.*s%s%-2u", lth-wp-2, w, dev, p, pno); } else { - snprintf(bufp, bufsiz, "%.*s%s%-2u", w, dev, p, pno); + snprintf(bufp, sizeof(bufp), "%.*s%s%-2u", w, dev, p, pno); } return bufp; } -char * -partname(char *dev, int pno, int lth) { - return partnamebf(dev, pno, lth, 0, NULL); -} -- 2.39.5