Module Name: src
Committed By: lukem
Date: Sat Apr 11 07:14:50 UTC 2009
Modified Files:
src/sbin/fsck_msdos: boot.c check.c dir.c ext.h fat.c
Log Message:
fix sign-compare issues
To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sbin/fsck_msdos/boot.c
cvs rdiff -u -r1.17 -r1.18 src/sbin/fsck_msdos/check.c
cvs rdiff -u -r1.22 -r1.23 src/sbin/fsck_msdos/dir.c
cvs rdiff -u -r1.12 -r1.13 src/sbin/fsck_msdos/ext.h
cvs rdiff -u -r1.21 -r1.22 src/sbin/fsck_msdos/fat.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sbin/fsck_msdos/boot.c
diff -u src/sbin/fsck_msdos/boot.c:1.14 src/sbin/fsck_msdos/boot.c:1.15
--- src/sbin/fsck_msdos/boot.c:1.14 Fri Jun 13 20:46:09 2008
+++ src/sbin/fsck_msdos/boot.c Sat Apr 11 07:14:50 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: boot.c,v 1.14 2008/06/13 20:46:09 martin Exp $ */
+/* $NetBSD: boot.c,v 1.15 2009/04/11 07:14:50 lukem Exp $ */
/*
* Copyright (C) 1995, 1997 Wolfgang Solfrank
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: boot.c,v 1.14 2008/06/13 20:46:09 martin Exp $");
+__RCSID("$NetBSD: boot.c,v 1.15 2009/04/11 07:14:50 lukem Exp $");
#endif /* not lint */
#include <stdlib.h>
@@ -48,7 +48,7 @@
int ret = FSOK;
int i;
- if (read(dosfs, block, sizeof block) < sizeof block) {
+ if ((size_t)read(dosfs, block, sizeof block) != sizeof block) {
perr("could not read boot block");
return FSFATAL;
}
Index: src/sbin/fsck_msdos/check.c
diff -u src/sbin/fsck_msdos/check.c:1.17 src/sbin/fsck_msdos/check.c:1.18
--- src/sbin/fsck_msdos/check.c:1.17 Fri Jun 13 20:46:09 2008
+++ src/sbin/fsck_msdos/check.c Sat Apr 11 07:14:50 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: check.c,v 1.17 2008/06/13 20:46:09 martin Exp $ */
+/* $NetBSD: check.c,v 1.18 2009/04/11 07:14:50 lukem Exp $ */
/*
* Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: check.c,v 1.17 2008/06/13 20:46:09 martin Exp $");
+__RCSID("$NetBSD: check.c,v 1.18 2009/04/11 07:14:50 lukem Exp $");
#endif /* not lint */
#include <stdlib.h>
@@ -47,7 +47,8 @@
int dosfs;
struct bootblock boot;
struct fatEntry *fat = NULL;
- int i, finish_dosdirsection=0;
+ int finish_dosdirsection=0;
+ u_int i;
int mod = 0;
int ret = FSCK_EXIT_CHECK_FAILED;
Index: src/sbin/fsck_msdos/dir.c
diff -u src/sbin/fsck_msdos/dir.c:1.22 src/sbin/fsck_msdos/dir.c:1.23
--- src/sbin/fsck_msdos/dir.c:1.22 Fri Jun 13 20:46:09 2008
+++ src/sbin/fsck_msdos/dir.c Sat Apr 11 07:14:50 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.22 2008/06/13 20:46:09 martin Exp $ */
+/* $NetBSD: dir.c,v 1.23 2009/04/11 07:14:50 lukem Exp $ */
/*
* Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank
@@ -30,7 +30,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: dir.c,v 1.22 2008/06/13 20:46:09 martin Exp $");
+__RCSID("$NetBSD: dir.c,v 1.23 2009/04/11 07:14:50 lukem Exp $");
#endif /* not lint */
#include <stdio.h>
@@ -393,7 +393,7 @@
/*
* Check size on ordinary files
*/
- int32_t physicalSize;
+ u_int32_t physicalSize;
if (dir->head == CLUST_FREE)
physicalSize = 0;
@@ -963,7 +963,7 @@
lfoff = lfcl * boot->ClusterSize
+ boot->ClusterOffset * boot->BytesPerSec;
if (lseek(dosfs, lfoff, SEEK_SET) != lfoff
- || read(dosfs, lfbuf, boot->ClusterSize) != boot->ClusterSize) {
+ || (size_t)read(dosfs, lfbuf, boot->ClusterSize) != boot->ClusterSize) {
perr("could not read LOST.DIR");
return FSFATAL;
}
@@ -993,7 +993,7 @@
p[31] = (u_char)(d.size >> 24);
fat[head].flags |= FAT_USED;
if (lseek(dosfs, lfoff, SEEK_SET) != lfoff
- || write(dosfs, lfbuf, boot->ClusterSize) != boot->ClusterSize) {
+ || (size_t)write(dosfs, lfbuf, boot->ClusterSize) != boot->ClusterSize) {
perr("could not write LOST.DIR");
return FSFATAL;
}
Index: src/sbin/fsck_msdos/ext.h
diff -u src/sbin/fsck_msdos/ext.h:1.12 src/sbin/fsck_msdos/ext.h:1.13
--- src/sbin/fsck_msdos/ext.h:1.12 Fri Jun 13 20:46:09 2008
+++ src/sbin/fsck_msdos/ext.h Sat Apr 11 07:14:50 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: ext.h,v 1.12 2008/06/13 20:46:09 martin Exp $ */
+/* $NetBSD: ext.h,v 1.13 2009/04/11 07:14:50 lukem Exp $ */
/*
* Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank
@@ -83,13 +83,13 @@
* Read one of the FAT copies and return a pointer to the new
* allocated array holding our description of it.
*/
-int readfat(int, struct bootblock *, int, struct fatEntry **);
+int readfat(int, struct bootblock *, u_int, struct fatEntry **);
/*
* Check two FAT copies for consistency and merge changes into the
* first if necessary.
*/
-int comparefat(struct bootblock *, struct fatEntry *, struct fatEntry *, int);
+int comparefat(struct bootblock *, struct fatEntry *, struct fatEntry *, u_int);
/*
* Check a FAT
Index: src/sbin/fsck_msdos/fat.c
diff -u src/sbin/fsck_msdos/fat.c:1.21 src/sbin/fsck_msdos/fat.c:1.22
--- src/sbin/fsck_msdos/fat.c:1.21 Thu Jul 24 14:23:16 2008
+++ src/sbin/fsck_msdos/fat.c Sat Apr 11 07:14:50 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: fat.c,v 1.21 2008/07/24 14:23:16 matthias Exp $ */
+/* $NetBSD: fat.c,v 1.22 2009/04/11 07:14:50 lukem Exp $ */
/*
* Copyright (C) 1995, 1996, 1997 Wolfgang Solfrank
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: fat.c,v 1.21 2008/07/24 14:23:16 matthias Exp $");
+__RCSID("$NetBSD: fat.c,v 1.22 2009/04/11 07:14:50 lukem Exp $");
#endif /* not lint */
#include <stdlib.h>
@@ -40,16 +40,16 @@
#include "ext.h"
#include "fsutil.h"
-static int checkclnum(struct bootblock *, int, cl_t, cl_t *);
-static int clustdiffer(cl_t, cl_t *, cl_t *, int);
+static int checkclnum(struct bootblock *, u_int, cl_t, cl_t *);
+static int clustdiffer(cl_t, cl_t *, cl_t *, u_int);
static int tryclear(struct bootblock *, struct fatEntry *, cl_t, cl_t *);
-static int _readfat(int, struct bootblock *, int, u_char **);
+static int _readfat(int, struct bootblock *, u_int, u_char **);
/*
* Check a cluster number for valid value
*/
static int
-checkclnum(struct bootblock *boot, int fat, cl_t cl, cl_t *next)
+checkclnum(struct bootblock *boot, u_int fat, cl_t cl, cl_t *next)
{
if (*next >= (CLUST_RSRVD&boot->ClustMask))
*next |= ~boot->ClustMask;
@@ -63,7 +63,7 @@
}
if (*next < CLUST_FIRST
|| (*next >= boot->NumClusters && *next < CLUST_EOFS)) {
- pwarn("Cluster %u in FAT %d continues with %s cluster number %u\n",
+ pwarn("Cluster %u in FAT %u continues with %s cluster number %u\n",
cl, fat,
*next < CLUST_RSRVD ? "out of range" : "reserved",
*next&boot->ClustMask);
@@ -80,7 +80,7 @@
* Read a FAT from disk. Returns 1 if successful, 0 otherwise.
*/
static int
-_readfat(int fs, struct bootblock *boot, int no, u_char **buffer)
+_readfat(int fs, struct bootblock *boot, u_int no, u_char **buffer)
{
off_t off;
size_t len;
@@ -99,7 +99,7 @@
goto err;
}
- if (read(fs, *buffer, boot->FATsecs * boot->BytesPerSec)
+ if ((size_t)read(fs, *buffer, boot->FATsecs * boot->BytesPerSec)
!= boot->FATsecs * boot->BytesPerSec) {
perr("Unable to read FAT");
goto err;
@@ -116,7 +116,7 @@
* Read a FAT and decode it into internal format
*/
int
-readfat(int fs, struct bootblock *boot, int no, struct fatEntry **fp)
+readfat(int fs, struct bootblock *boot, u_int no, struct fatEntry **fp)
{
struct fatEntry *fat;
u_char *buffer, *p;
@@ -252,7 +252,7 @@
}
static int
-clustdiffer(cl_t cl, cl_t *cp1, cl_t *cp2, int fatnum)
+clustdiffer(cl_t cl, cl_t *cp1, cl_t *cp2, u_int fatnum)
{
if (*cp1 == CLUST_FREE || *cp1 >= CLUST_RSRVD) {
if (*cp2 == CLUST_FREE || *cp2 >= CLUST_RSRVD) {
@@ -267,21 +267,21 @@
}
return FSFATAL;
}
- pwarn("Cluster %u is marked %s in FAT 0, %s in FAT %d\n",
+ pwarn("Cluster %u is marked %s in FAT 0, %s in FAT %u\n",
cl, rsrvdcltype(*cp1), rsrvdcltype(*cp2), fatnum);
if (ask(0, "use FAT 0's entry")) {
*cp2 = *cp1;
return FSFATMOD;
}
- if (ask(0, "use FAT %d's entry", fatnum)) {
+ if (ask(0, "use FAT %u's entry", fatnum)) {
*cp1 = *cp2;
return FSFATMOD;
}
return FSFATAL;
}
- pwarn("Cluster %u is marked %s in FAT 0, but continues with cluster %u in FAT %d\n",
+ pwarn("Cluster %u is marked %s in FAT 0, but continues with cluster %u in FAT %u\n",
cl, rsrvdcltype(*cp1), *cp2, fatnum);
- if (ask(0, "Use continuation from FAT %d", fatnum)) {
+ if (ask(0, "Use continuation from FAT %u", fatnum)) {
*cp1 = *cp2;
return FSFATMOD;
}
@@ -292,25 +292,25 @@
return FSFATAL;
}
if (*cp2 == CLUST_FREE || *cp2 >= CLUST_RSRVD) {
- pwarn("Cluster %u continues with cluster %u in FAT 0, but is marked %s in FAT %d\n",
+ pwarn("Cluster %u continues with cluster %u in FAT 0, but is marked %s in FAT %u\n",
cl, *cp1, rsrvdcltype(*cp2), fatnum);
if (ask(0, "Use continuation from FAT 0")) {
*cp2 = *cp1;
return FSFATMOD;
}
- if (ask(0, "Use mark from FAT %d", fatnum)) {
+ if (ask(0, "Use mark from FAT %u", fatnum)) {
*cp1 = *cp2;
return FSFATMOD;
}
return FSERROR;
}
- pwarn("Cluster %u continues with cluster %u in FAT 0, but with cluster %u in FAT %d\n",
+ pwarn("Cluster %u continues with cluster %u in FAT 0, but with cluster %u in FAT %u\n",
cl, *cp1, *cp2, fatnum);
if (ask(0, "Use continuation from FAT 0")) {
*cp2 = *cp1;
return FSFATMOD;
}
- if (ask(0, "Use continuation from FAT %d", fatnum)) {
+ if (ask(0, "Use continuation from FAT %u", fatnum)) {
*cp1 = *cp2;
return FSFATMOD;
}
@@ -323,7 +323,7 @@
*/
int
comparefat(struct bootblock *boot, struct fatEntry *first,
- struct fatEntry *second, int fatnum)
+ struct fatEntry *second, u_int fatnum)
{
cl_t cl;
int ret = FSOK;
@@ -463,7 +463,7 @@
{
u_char *buffer, *p;
cl_t cl;
- int i;
+ u_int i;
size_t fatsz;
off_t off;
int ret = FSOK;
@@ -554,7 +554,7 @@
off = boot->ResSectors + i * boot->FATsecs;
off *= boot->BytesPerSec;
if (lseek(fs, off, SEEK_SET) != off
- || write(fs, buffer, fatsz) != fatsz) {
+ || (size_t)write(fs, buffer, fatsz) != fatsz) {
perr("Unable to write FAT");
ret = FSFATAL; /* Return immediately? XXX */
}