Browse Source

Use a constant format string and output the variable part with %s

ok krw@ millert@
OPENBSD_6_1
guenther 8 years ago
parent
commit
487debcae6
1 changed files with 11 additions and 11 deletions
  1. +11
    -11
      src/lib/libutil/uucplock.c

+ 11
- 11
src/lib/libutil/uucplock.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: uucplock.c,v 1.18 2016/08/30 14:44:45 guenther Exp $ */
/* $OpenBSD: uucplock.c,v 1.19 2016/08/30 14:52:09 guenther Exp $ */
/* /*
* Copyright (c) 1988, 1993 * Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved. * The Regents of the University of California. All rights reserved.
@ -153,7 +153,7 @@ const char *
uu_lockerr(int uu_lockresult) uu_lockerr(int uu_lockresult)
{ {
static char errbuf[128]; static char errbuf[128];
char *fmt;
const char *err;
switch (uu_lockresult) { switch (uu_lockresult) {
case UU_LOCK_INUSE: case UU_LOCK_INUSE:
@ -161,32 +161,32 @@ uu_lockerr(int uu_lockresult)
case UU_LOCK_OK: case UU_LOCK_OK:
return ""; return "";
case UU_LOCK_OPEN_ERR: case UU_LOCK_OPEN_ERR:
fmt = "open error: %s";
err = "open error";
break; break;
case UU_LOCK_READ_ERR: case UU_LOCK_READ_ERR:
fmt = "read error: %s";
err = "read error";
break; break;
case UU_LOCK_CREAT_ERR: case UU_LOCK_CREAT_ERR:
fmt = "creat error: %s";
err = "creat error";
break; break;
case UU_LOCK_WRITE_ERR: case UU_LOCK_WRITE_ERR:
fmt = "write error: %s";
err = "write error";
break; break;
case UU_LOCK_LINK_ERR: case UU_LOCK_LINK_ERR:
fmt = "link error: %s";
err = "link error";
break; break;
case UU_LOCK_TRY_ERR: case UU_LOCK_TRY_ERR:
fmt = "too many tries: %s";
err = "too many tries";
break; break;
case UU_LOCK_OWNER_ERR: case UU_LOCK_OWNER_ERR:
fmt = "not locking process: %s";
err = "not locking process";
break; break;
default: default:
fmt = "undefined error: %s";
err = "undefined error";
break; break;
} }
(void)snprintf(errbuf, sizeof(errbuf), fmt, strerror(errno));
(void)snprintf(errbuf, sizeof(errbuf), "%s: %s", err, strerror(errno));
return errbuf; return errbuf;
} }


Loading…
Cancel
Save