Wed Jan 23 20:27:01 2013 UTC ()
Move assignment out of assertion in cap_mkdb.


(riastradh)
diff -r1.27 -r1.28 src/usr.bin/cap_mkdb/cap_mkdb.c

cvs diff -r1.27 -r1.28 src/usr.bin/cap_mkdb/cap_mkdb.c (expand / switch to unified diff)

--- src/usr.bin/cap_mkdb/cap_mkdb.c 2011/08/29 13:56:17 1.27
+++ src/usr.bin/cap_mkdb/cap_mkdb.c 2013/01/23 20:27:01 1.28
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: cap_mkdb.c,v 1.27 2011/08/29 13:56:17 joerg Exp $ */ 1/* $NetBSD: cap_mkdb.c,v 1.28 2013/01/23 20:27:01 riastradh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1992, 1993 4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -30,27 +30,27 @@ @@ -30,27 +30,27 @@
30 */ 30 */
31 31
32#if HAVE_NBTOOL_CONFIG_H 32#if HAVE_NBTOOL_CONFIG_H
33#include "nbtool_config.h" 33#include "nbtool_config.h"
34#endif 34#endif
35 35
36#include <sys/cdefs.h> 36#include <sys/cdefs.h>
37#if !defined(lint) 37#if !defined(lint)
38__COPYRIGHT("@(#) Copyright (c) 1992, 1993\ 38__COPYRIGHT("@(#) Copyright (c) 1992, 1993\
39 The Regents of the University of California. All rights reserved."); 39 The Regents of the University of California. All rights reserved.");
40#if 0 40#if 0
41static char sccsid[] = "@(#)cap_mkdb.c 8.2 (Berkeley) 4/27/95"; 41static char sccsid[] = "@(#)cap_mkdb.c 8.2 (Berkeley) 4/27/95";
42#endif 42#endif
43__RCSID("$NetBSD: cap_mkdb.c,v 1.27 2011/08/29 13:56:17 joerg Exp $"); 43__RCSID("$NetBSD: cap_mkdb.c,v 1.28 2013/01/23 20:27:01 riastradh Exp $");
44#endif /* not lint */ 44#endif /* not lint */
45 45
46#include <sys/param.h> 46#include <sys/param.h>
47#include <sys/stat.h> 47#include <sys/stat.h>
48 48
49#include <assert.h> 49#include <assert.h>
50#include <db.h> 50#include <db.h>
51#include <err.h> 51#include <err.h>
52#include <fcntl.h> 52#include <fcntl.h>
53#include <stdio.h> 53#include <stdio.h>
54#include <stdlib.h> 54#include <stdlib.h>
55#include <string.h> 55#include <string.h>
56#include <unistd.h> 56#include <unistd.h>
@@ -131,27 +131,28 @@ main(int argc, char *argv[]) @@ -131,27 +131,28 @@ main(int argc, char *argv[])
131 if ((capname = strdup(buf)) == NULL) 131 if ((capname = strdup(buf)) == NULL)
132 err(1, "strdup"); 132 err(1, "strdup");
133 if ((capdbp = dbopen(capname, O_CREAT | O_TRUNC | O_RDWR, 133 if ((capdbp = dbopen(capname, O_CREAT | O_TRUNC | O_RDWR,
134 DEFFILEMODE, DB_HASH, &openinfo)) == NULL) 134 DEFFILEMODE, DB_HASH, &openinfo)) == NULL)
135 err(1, "%s", buf); 135 err(1, "%s", buf);
136 136
137 if (atexit(dounlink)) 137 if (atexit(dounlink))
138 err(1, "atexit"); 138 err(1, "atexit");
139 139
140 db_build((void *)argv); 140 db_build((void *)argv);
141 141
142 if (capdbp->close(capdbp) < 0) 142 if (capdbp->close(capdbp) < 0)
143 err(1, "%s", capname); 143 err(1, "%s", capname);
144 assert((p = strrchr(buf, '.')) != NULL); 144 p = strrchr(buf, '.');
 145 assert(p != NULL);
145 *p = '\0'; 146 *p = '\0';
146 if (rename(capname, buf) == -1) 147 if (rename(capname, buf) == -1)
147 err(1, "rename"); 148 err(1, "rename");
148 free(capname); 149 free(capname);
149 capname = NULL; 150 capname = NULL;
150 return 0; 151 return 0;
151} 152}
152 153
153static void 154static void
154dounlink(void) 155dounlink(void)
155{ 156{
156 if (capname != NULL) 157 if (capname != NULL)
157 (void)unlink(capname); 158 (void)unlink(capname);