mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-12-24 10:52:36 +01:00
Turn dkcksum() into an __inline function.
Change its type to u_int_16_t.
This commit is contained in:
parent
c80d29139c
commit
fc87418be0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=65921
@ -1,7 +1,7 @@
|
||||
# $FreeBSD$
|
||||
|
||||
LIB= disk
|
||||
SRCS= blocks.c disklabel.c dkcksum.c chunk.c disk.c change.c \
|
||||
SRCS= blocks.c disklabel.c chunk.c disk.c change.c \
|
||||
create_chunk.c rules.c write_disk.c
|
||||
INCS= libdisk.h
|
||||
|
||||
@ -10,7 +10,6 @@ CFLAGS+= -Wall
|
||||
CFLAGS+= -DPC98
|
||||
.endif
|
||||
CLEANFILES+= tmp.c tst01 tst01.o
|
||||
VPATH= ${.CURDIR}/../../sbin/disklabel
|
||||
NOPROFILE= yes
|
||||
NOSHARED= yes
|
||||
NOPIC= yes
|
||||
|
@ -265,7 +265,6 @@ int Add_Chunk(struct disk *, long, u_long, const char *, chunk_e, int, u_long);
|
||||
void * read_block(int, daddr_t);
|
||||
void write_block(int fd, daddr_t block, void *foo);
|
||||
struct disklabel * read_disklabel(int, daddr_t);
|
||||
u_short dkcksum(struct disklabel *);
|
||||
struct chunk * Find_Mother_Chunk(struct chunk *, u_long, u_long, chunk_e);
|
||||
struct disk * Int_Open_Disk(const char *name, u_long size);
|
||||
void Fixup_Names(struct disk *);
|
||||
|
@ -212,7 +212,6 @@ extern void free_region(void *start, void *end);
|
||||
/* disklabel support (undocumented, may be junk) */
|
||||
struct disklabel;
|
||||
extern char *getdisklabel(const char *, struct disklabel *);
|
||||
extern int dkcksum(struct disklabel *);
|
||||
|
||||
extern int printf(const char *fmt, ...);
|
||||
extern void vprintf(const char *fmt, _BSD_VA_LIST_);
|
||||
|
@ -2,7 +2,7 @@
|
||||
# $FreeBSD$
|
||||
|
||||
PROG= disklabel
|
||||
SRCS= disklabel.c dkcksum.c
|
||||
SRCS= disklabel.c
|
||||
MAN8= disklabel.8
|
||||
MAN5= disklabel.5
|
||||
|
||||
|
@ -105,7 +105,6 @@ int checklabel __P((struct disklabel *));
|
||||
void setbootflag __P((struct disklabel *));
|
||||
void Warning (char *, ...);
|
||||
void usage __P((void));
|
||||
extern u_short dkcksum __P((struct disklabel *));
|
||||
struct disklabel * getvirginlabel __P((void));
|
||||
|
||||
#define DEFEDITOR _PATH_VI
|
||||
|
@ -1,57 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)dkcksum.c 8.1 (Berkeley) 6/5/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/disklabel.h>
|
||||
|
||||
u_short
|
||||
dkcksum(lp)
|
||||
register struct disklabel *lp;
|
||||
{
|
||||
register u_short *start, *end;
|
||||
register u_short sum = 0;
|
||||
|
||||
start = (u_short *)lp;
|
||||
end = (u_short *)&lp->d_partitions[lp->d_npartitions];
|
||||
while (start < end)
|
||||
sum ^= *start++;
|
||||
return (sum);
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
# $FreeBSD$
|
||||
|
||||
PROG= disklabel
|
||||
SRCS= disklabel.c dkcksum.c
|
||||
SRCS= disklabel.c
|
||||
MAN8= disklabel.8
|
||||
MAN5= disklabel.5
|
||||
|
||||
|
@ -105,7 +105,6 @@ int checklabel __P((struct disklabel *));
|
||||
void setbootflag __P((struct disklabel *));
|
||||
void Warning (char *, ...);
|
||||
void usage __P((void));
|
||||
extern u_short dkcksum __P((struct disklabel *));
|
||||
struct disklabel * getvirginlabel __P((void));
|
||||
|
||||
#define DEFEDITOR _PATH_VI
|
||||
|
@ -1,57 +0,0 @@
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
#if 0
|
||||
static char sccsid[] = "@(#)dkcksum.c 8.1 (Berkeley) 6/5/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$FreeBSD$";
|
||||
#endif /* not lint */
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/disklabel.h>
|
||||
|
||||
u_short
|
||||
dkcksum(lp)
|
||||
register struct disklabel *lp;
|
||||
{
|
||||
register u_short *start, *end;
|
||||
register u_short sum = 0;
|
||||
|
||||
start = (u_short *)lp;
|
||||
end = (u_short *)&lp->d_partitions[lp->d_npartitions];
|
||||
while (start < end)
|
||||
sum ^= *start++;
|
||||
return (sum);
|
||||
}
|
@ -1,12 +1,13 @@
|
||||
# @(#)Makefile 8.2 (Berkeley) 3/27/94
|
||||
# $FreeBSD$
|
||||
|
||||
PROG= newfs
|
||||
SRCS= dkcksum.c getmntopts.c newfs.c mkfs.c
|
||||
SRCS= getmntopts.c newfs.c mkfs.c
|
||||
MAN8= newfs.8
|
||||
|
||||
MOUNT= ${.CURDIR}/../mount
|
||||
CFLAGS+=-DMFS -DFSIRAND -I${MOUNT}
|
||||
.PATH: ${MOUNT} ${.CURDIR}/../disklabel
|
||||
.PATH: ${MOUNT}
|
||||
|
||||
LINKS= ${BINDIR}/newfs ${BINDIR}/mount_mfs
|
||||
MLINKS= newfs.8 mount_mfs.8 newfs.8 mfs.8 newfs.8 tmpfs.8
|
||||
|
@ -323,23 +323,6 @@ done:
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* Compute checksum for disk label.
|
||||
*/
|
||||
u_int
|
||||
dkcksum(lp)
|
||||
register struct disklabel *lp;
|
||||
{
|
||||
register u_short *start, *end;
|
||||
register u_short sum = 0;
|
||||
|
||||
start = (u_short *)lp;
|
||||
end = (u_short *)&lp->d_partitions[lp->d_npartitions];
|
||||
while (start < end)
|
||||
sum ^= *start++;
|
||||
return (sum);
|
||||
}
|
||||
|
||||
/*
|
||||
* Disk error is the preface to plaintive error messages
|
||||
* about failing disk transfers. It prints messages of the form
|
||||
|
@ -180,6 +180,21 @@ struct disklabel {
|
||||
#define p_sgs __partition_u1.sgs
|
||||
} d_partitions[MAXPARTITIONS]; /* actually may be more */
|
||||
};
|
||||
|
||||
static __inline u_int16_t
|
||||
dkcksum(lp)
|
||||
struct disklabel *lp;
|
||||
{
|
||||
u_int16_t *start, *end;
|
||||
u_int16_t sum = 0;
|
||||
|
||||
start = (u_int16_t *)lp;
|
||||
end = (u_int16_t *)&lp->d_partitions[lp->d_npartitions];
|
||||
while (start < end)
|
||||
sum ^= *start++;
|
||||
return (sum);
|
||||
}
|
||||
|
||||
#else /* LOCORE */
|
||||
/*
|
||||
* offsets for asm boot files.
|
||||
@ -449,7 +464,6 @@ int bounds_check_with_label __P((struct bio *bp, struct disklabel *lp,
|
||||
void diskerr __P((struct bio *bp, char *what, int pri, int blkdone,
|
||||
struct disklabel *lp));
|
||||
void disksort __P((struct buf *ap, struct buf *bp));
|
||||
u_int dkcksum __P((struct disklabel *lp));
|
||||
char *readdisklabel __P((dev_t dev, struct disklabel *lp));
|
||||
void bioqdisksort __P((struct bio_queue_head *ap, struct bio *bp));
|
||||
int setdisklabel __P((struct disklabel *olp, struct disklabel *nlp,
|
||||
|
@ -180,6 +180,21 @@ struct disklabel {
|
||||
#define p_sgs __partition_u1.sgs
|
||||
} d_partitions[MAXPARTITIONS]; /* actually may be more */
|
||||
};
|
||||
|
||||
static __inline u_int16_t
|
||||
dkcksum(lp)
|
||||
struct disklabel *lp;
|
||||
{
|
||||
u_int16_t *start, *end;
|
||||
u_int16_t sum = 0;
|
||||
|
||||
start = (u_int16_t *)lp;
|
||||
end = (u_int16_t *)&lp->d_partitions[lp->d_npartitions];
|
||||
while (start < end)
|
||||
sum ^= *start++;
|
||||
return (sum);
|
||||
}
|
||||
|
||||
#else /* LOCORE */
|
||||
/*
|
||||
* offsets for asm boot files.
|
||||
@ -449,7 +464,6 @@ int bounds_check_with_label __P((struct bio *bp, struct disklabel *lp,
|
||||
void diskerr __P((struct bio *bp, char *what, int pri, int blkdone,
|
||||
struct disklabel *lp));
|
||||
void disksort __P((struct buf *ap, struct buf *bp));
|
||||
u_int dkcksum __P((struct disklabel *lp));
|
||||
char *readdisklabel __P((dev_t dev, struct disklabel *lp));
|
||||
void bioqdisksort __P((struct bio_queue_head *ap, struct bio *bp));
|
||||
int setdisklabel __P((struct disklabel *olp, struct disklabel *nlp,
|
||||
|
@ -180,6 +180,21 @@ struct disklabel {
|
||||
#define p_sgs __partition_u1.sgs
|
||||
} d_partitions[MAXPARTITIONS]; /* actually may be more */
|
||||
};
|
||||
|
||||
static __inline u_int16_t
|
||||
dkcksum(lp)
|
||||
struct disklabel *lp;
|
||||
{
|
||||
u_int16_t *start, *end;
|
||||
u_int16_t sum = 0;
|
||||
|
||||
start = (u_int16_t *)lp;
|
||||
end = (u_int16_t *)&lp->d_partitions[lp->d_npartitions];
|
||||
while (start < end)
|
||||
sum ^= *start++;
|
||||
return (sum);
|
||||
}
|
||||
|
||||
#else /* LOCORE */
|
||||
/*
|
||||
* offsets for asm boot files.
|
||||
@ -449,7 +464,6 @@ int bounds_check_with_label __P((struct bio *bp, struct disklabel *lp,
|
||||
void diskerr __P((struct bio *bp, char *what, int pri, int blkdone,
|
||||
struct disklabel *lp));
|
||||
void disksort __P((struct buf *ap, struct buf *bp));
|
||||
u_int dkcksum __P((struct disklabel *lp));
|
||||
char *readdisklabel __P((dev_t dev, struct disklabel *lp));
|
||||
void bioqdisksort __P((struct bio_queue_head *ap, struct bio *bp));
|
||||
int setdisklabel __P((struct disklabel *olp, struct disklabel *nlp,
|
||||
|
Loading…
Reference in New Issue
Block a user