constification fixes.

This commit is contained in:
christos 2004-06-30 13:59:22 +00:00
parent 84a3bc854d
commit b508e54615
3 changed files with 29 additions and 30 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: disklabel.c,v 1.6 2003/08/07 16:32:26 agc Exp $ */
/* $NetBSD: disklabel.c,v 1.7 2004/06/30 13:59:22 christos Exp $ */
/*-
* Copyright (c) 1993
@ -35,36 +35,36 @@
#include <sys/disklabel.h>
#include "stand.h"
#if defined(LIBSA_NO_DISKLABEL_MSGS)
#define nolabel (char *)1
#define corruptedlabel (char *)1
#else
static char nolabel[] = "no disk label";
static char corruptedlabel[] = "disk label corrupted";
#endif
char *
getdisklabel(buf, lp)
const char *buf;
struct disklabel *lp;
{
struct disklabel *dlp, *elp;
char *msg = (char *)0;
const struct disklabel *dlp, *elp;
char *msg = NULL;
elp = (struct disklabel *)(buf + DEV_BSIZE - sizeof(*dlp));
for (dlp = (struct disklabel *)buf; dlp <= elp;
dlp = (struct disklabel *)((char *)dlp + sizeof(long))) {
elp = (const void *)(buf + DEV_BSIZE - sizeof(*dlp));
for (dlp = (const void *)buf; dlp <= elp;
dlp = (const void *)((const char *)dlp + sizeof(long))) {
if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC) {
#if defined(LIBSA_NO_DISKLABEL_MSGS)
msg = (char *)1;
#else
if (msg == (char *)0)
msg = "no disk label";
#endif
if (msg == NULL)
msg = nolabel;
} else if (dlp->d_npartitions > MAXPARTITIONS ||
dkcksum(dlp) != 0)
#if defined(LIBSA_NO_DISKLABEL_MSGS)
msg = (char *)1;
#else
msg = "disk label corrupted";
#endif
msg = corruptedlabel;
else {
bcopy(dlp, lp, sizeof *lp);
msg = (char *)0;
(void)memcpy(lp, dlp, sizeof *lp);
msg = NULL;
break;
}
}
return (msg);
return msg;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: dkcksum.c,v 1.3 2003/08/07 16:32:26 agc Exp $ */
/* $NetBSD: dkcksum.c,v 1.4 2004/06/30 13:59:22 christos Exp $ */
/*-
* Copyright (c) 1993
@ -39,15 +39,14 @@
* Compute checksum for disk label.
*/
int
dkcksum(lp)
struct disklabel *lp;
dkcksum(const struct disklabel *lp)
{
u_short *start, *end;
const u_short *start, *end;
u_short sum = 0;
start = (u_short *)lp;
end = (u_short *)&lp->d_partitions[lp->d_npartitions];
start = (const void *)lp;
end = (const void *)&lp->d_partitions[lp->d_npartitions];
while (start < end)
sum ^= *start++;
return (sum);
return sum;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: strerror.c,v 1.16 2003/08/07 16:32:30 agc Exp $ */
/* $NetBSD: strerror.c,v 1.17 2004/06/30 13:59:22 christos Exp $ */
/*-
* Copyright (c) 1993
@ -35,7 +35,7 @@
static const struct mi {
int errno;
char *msg;
const char *msg;
} errlist[] = {
{ EADAPT, "bad adaptor number" },
{ ECTLR, "bad controller number" },
@ -64,7 +64,7 @@ strerror(int err)
for (mi = errlist; mi->msg; mi++)
if (mi->errno == err)
return mi->msg;
return __DECONST(mi->msg);
snprintf(ebuf, sizeof ebuf, "Unknown error: code %d", err);
return ebuf;