Sat Jul 12 19:44:00 2014 UTC ()
Remove pointless function indirection through panic_func(). It was
initialized to one thing, and then set to another right at the top of
main and never changed again.


(dholland)
diff -r1.41 -r1.42 src/sbin/fsck_lfs/lfs.c
diff -r1.46 -r1.47 src/sbin/fsck_lfs/main.c

cvs diff -r1.41 -r1.42 src/sbin/fsck_lfs/lfs.c (expand / switch to unified diff)

--- src/sbin/fsck_lfs/lfs.c 2013/10/19 01:09:58 1.41
+++ src/sbin/fsck_lfs/lfs.c 2014/07/12 19:44:00 1.42
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: lfs.c,v 1.41 2013/10/19 01:09:58 christos Exp $ */ 1/* $NetBSD: lfs.c,v 1.42 2014/07/12 19:44:00 dholland Exp $ */
2/*- 2/*-
3 * Copyright (c) 2003 The NetBSD Foundation, Inc. 3 * Copyright (c) 2003 The NetBSD Foundation, Inc.
4 * All rights reserved. 4 * All rights reserved.
5 * 5 *
6 * This code is derived from software contributed to The NetBSD Foundation 6 * This code is derived from software contributed to The NetBSD Foundation
7 * by Konrad E. Schroder <perseant@hhhh.org>. 7 * by Konrad E. Schroder <perseant@hhhh.org>.
8 * 8 *
9 * Redistribution and use in source and binary forms, with or without 9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions 10 * modification, are permitted provided that the following conditions
11 * are met: 11 * are met:
12 * 1. Redistributions of source code must retain the above copyright 12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer. 13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright 14 * 2. Redistributions in binary form must reproduce the above copyright
@@ -75,49 +75,49 @@ @@ -75,49 +75,49 @@
75#include <ufs/lfs/lfs_inode.h> 75#include <ufs/lfs/lfs_inode.h>
76#undef vnode 76#undef vnode
77 77
78#include <assert.h> 78#include <assert.h>
79#include <err.h> 79#include <err.h>
80#include <errno.h> 80#include <errno.h>
81#include <stdarg.h> 81#include <stdarg.h>
82#include <stdio.h> 82#include <stdio.h>
83#include <stdlib.h> 83#include <stdlib.h>
84#include <string.h> 84#include <string.h>
85#include <unistd.h> 85#include <unistd.h>
86#include <util.h> 86#include <util.h>
87 87
 88#include "fsutil.h"
88#include "bufcache.h" 89#include "bufcache.h"
89#include "vnode.h" 90#include "vnode.h"
90#include "lfs_user.h" 91#include "lfs_user.h"
91#include "segwrite.h" 92#include "segwrite.h"
92#include "kernelops.h" 93#include "kernelops.h"
93 94
94#define panic call_panic 95#define panic call_panic
95 96
96extern u_int32_t cksum(void *, size_t); 97extern u_int32_t cksum(void *, size_t);
97extern u_int32_t lfs_sb_cksum(struct dlfs *); 98extern u_int32_t lfs_sb_cksum(struct dlfs *);
98extern void pwarn(const char *, ...); 99extern void pwarn(const char *, ...);
99 100
100extern struct uvnodelst vnodelist; 101extern struct uvnodelst vnodelist;
101extern struct uvnodelst getvnodelist[VNODE_HASH_MAX]; 102extern struct uvnodelst getvnodelist[VNODE_HASH_MAX];
102extern int nvnodes; 103extern int nvnodes;
103 104
104long dev_bsize = DEV_BSIZE; 105long dev_bsize = DEV_BSIZE;
105 106
106static int 107static int
107lfs_fragextend(struct uvnode *, int, int, daddr_t, struct ubuf **); 108lfs_fragextend(struct uvnode *, int, int, daddr_t, struct ubuf **);
108 109
109int fsdirty = 0; 110int fsdirty = 0;
110void (*panic_func)(int, const char *, va_list) = my_vpanic; 
111 111
112/* 112/*
113 * LFS buffer and uvnode operations 113 * LFS buffer and uvnode operations
114 */ 114 */
115 115
116int 116int
117lfs_vop_strategy(struct ubuf * bp) 117lfs_vop_strategy(struct ubuf * bp)
118{ 118{
119 int count; 119 int count;
120 120
121 if (bp->b_flags & B_READ) { 121 if (bp->b_flags & B_READ) {
122 count = kops.ko_pread(bp->b_vp->v_fd, bp->b_data, bp->b_bcount, 122 count = kops.ko_pread(bp->b_vp->v_fd, bp->b_data, bp->b_bcount,
123 bp->b_blkno * dev_bsize); 123 bp->b_blkno * dev_bsize);
@@ -825,39 +825,32 @@ check_summary(struct lfs *fs, SEGSUM *sp @@ -825,39 +825,32 @@ check_summary(struct lfs *fs, SEGSUM *sp
825 pwarn("Partial segment at 0x%" PRIx32 " data checksum" 825 pwarn("Partial segment at 0x%" PRIx32 " data checksum"
826 " mismatch: given 0x%x, computed 0x%x\n", 826 " mismatch: given 0x%x, computed 0x%x\n",
827 pseg_addr, sp->ss_datasum, ccksum); 827 pseg_addr, sp->ss_datasum, ccksum);
828 free(datap); 828 free(datap);
829 return 0; 829 return 0;
830 } 830 }
831 free(datap); 831 free(datap);
832 assert(bc >= 0); 832 assert(bc >= 0);
833 return bc; 833 return bc;
834} 834}
835 835
836/* print message and exit */ 836/* print message and exit */
837void 837void
838my_vpanic(int fatal, const char *fmt, va_list ap) 
839{ 
840 (void) vprintf(fmt, ap); 
841 exit(8); 
842} 
843 
844void 
845call_panic(const char *fmt, ...) 838call_panic(const char *fmt, ...)
846{ 839{
847 va_list ap; 840 va_list ap;
848 841
849 va_start(ap, fmt); 842 va_start(ap, fmt);
850 panic_func(1, fmt, ap); 843 vmsg(1, fmt, ap);
851 va_end(ap); 844 va_end(ap);
852} 845}
853 846
854/* Allocate a new inode. */ 847/* Allocate a new inode. */
855struct uvnode * 848struct uvnode *
856lfs_valloc(struct lfs *fs, ino_t ino) 849lfs_valloc(struct lfs *fs, ino_t ino)
857{ 850{
858 struct ubuf *bp, *cbp; 851 struct ubuf *bp, *cbp;
859 struct ifile *ifp; 852 struct ifile *ifp;
860 ino_t new_ino; 853 ino_t new_ino;
861 int error; 854 int error;
862 CLEANERINFO *cip; 855 CLEANERINFO *cip;
863 856

cvs diff -r1.46 -r1.47 src/sbin/fsck_lfs/main.c (expand / switch to unified diff)

--- src/sbin/fsck_lfs/main.c 2014/07/12 16:11:27 1.46
+++ src/sbin/fsck_lfs/main.c 2014/07/12 19:44:00 1.47
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: main.c,v 1.46 2014/07/12 16:11:27 dholland Exp $ */ 1/* $NetBSD: main.c,v 1.47 2014/07/12 19:44:00 dholland Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1980, 1986, 1993 4 * Copyright (c) 1980, 1986, 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.
@@ -47,51 +47,49 @@ @@ -47,51 +47,49 @@
47#include <signal.h> 47#include <signal.h>
48 48
49#include "fsck.h" 49#include "fsck.h"
50#include "extern.h" 50#include "extern.h"
51#include "fsutil.h" 51#include "fsutil.h"
52#include "exitvalues.h" 52#include "exitvalues.h"
53 53
54volatile sig_atomic_t returntosingle = 0; 54volatile sig_atomic_t returntosingle = 0;
55 55
56static int argtoi(int, const char *, const char *, int); 56static int argtoi(int, const char *, const char *, int);
57static int checkfilesys(const char *, char *, long, int); 57static int checkfilesys(const char *, char *, long, int);
58static void usage(void); 58static void usage(void);
59static void efun(int, const char *, ...); 59static void efun(int, const char *, ...);
60extern void (*panic_func)(int, const char *, va_list); 
61 60
62static void 61static void
63efun(int eval, const char *fmt, ...) 62efun(int eval, const char *fmt, ...)
64{ 63{
65 va_list ap; 64 va_list ap;
66 va_start(ap, fmt); 65 va_start(ap, fmt);
67 verr(EEXIT, fmt, ap); 66 verr(EEXIT, fmt, ap);
68 va_end(ap); 67 va_end(ap);
69} 68}
70 69
71int 70int
72main(int argc, char **argv) 71main(int argc, char **argv)
73{ 72{
74 int ch; 73 int ch;
75 int ret = FSCK_EXIT_OK; 74 int ret = FSCK_EXIT_OK;
76 const char *optstring = "b:dfi:m:npPqUy"; 75 const char *optstring = "b:dfi:m:npPqUy";
77 bool reallypreen; 76 bool reallypreen;
78 77
79 reallypreen = false; 78 reallypreen = false;
80 ckfinish = ckfini; 79 ckfinish = ckfini;
81 skipclean = 1; 80 skipclean = 1;
82 exitonfail = 0; 81 exitonfail = 0;
83 idaddr = 0x0; 82 idaddr = 0x0;
84 panic_func = vmsg; 
85 esetfunc(efun); 83 esetfunc(efun);
86 while ((ch = getopt(argc, argv, optstring)) != -1) { 84 while ((ch = getopt(argc, argv, optstring)) != -1) {
87 switch (ch) { 85 switch (ch) {
88 case 'b': 86 case 'b':
89 skipclean = 0; 87 skipclean = 0;
90 bflag = argtoi('b', "number", optarg, 0); 88 bflag = argtoi('b', "number", optarg, 0);
91 printf("Alternate super block location: %d\n", bflag); 89 printf("Alternate super block location: %d\n", bflag);
92 break; 90 break;
93 case 'd': 91 case 'd':
94 debug++; 92 debug++;
95 break; 93 break;
96 case 'e': 94 case 'e':
97 exitonfail++; 95 exitonfail++;