coverity CID 515: Use assert.

This commit is contained in:
christos 2009-02-18 20:00:32 +00:00
parent f5e9e80946
commit e60db6c82e

View File

@ -1,4 +1,4 @@
/* $NetBSD: cap_mkdb.c,v 1.24 2008/07/21 14:19:21 lukem Exp $ */
/* $NetBSD: cap_mkdb.c,v 1.25 2009/02/18 20:00:32 christos Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -40,12 +40,13 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993\
#if 0
static char sccsid[] = "@(#)cap_mkdb.c 8.2 (Berkeley) 4/27/95";
#endif
__RCSID("$NetBSD: cap_mkdb.c,v 1.24 2008/07/21 14:19:21 lukem Exp $");
__RCSID("$NetBSD: cap_mkdb.c,v 1.25 2009/02/18 20:00:32 christos Exp $");
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#include <assert.h>
#include <db.h>
#include <err.h>
#include <fcntl.h>
@ -84,6 +85,7 @@ int
main(int argc, char *argv[])
{
int c, byteorder;
char *p;
capname = NULL;
byteorder = 0;
@ -139,7 +141,8 @@ main(int argc, char *argv[])
if (capdbp->close(capdbp) < 0)
err(1, "%s", capname);
*strrchr(buf, '.') = '\0';
assert((p = strrchr(buf, '.')) != NULL);
*p = '\0';
if (rename(capname, buf) == -1)
err(1, "rename");
free(capname);