- Align the function prototype of the external `crc' function with
how `crc' is actually defined. Data type corrections: - Define variables which contain file byte offset values as type off_t as required by the `crc' function. - Change the type of a variable carrying a CRC checksum from `u_long' to `uint32_t'. - Parse the length of a file with sscanf as `intmax_t' (as there is no conversion specifier for `off_t'). Style(9): - Put an empty line between #include directives for system and user header files.
This commit is contained in:
parent
60b588eb94
commit
fadcf8aec0
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=112213
@ -32,17 +32,19 @@ static const char rcsid[] =
|
|||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <fts.h>
|
#include <fts.h>
|
||||||
#include <md5.h>
|
#include <md5.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
extern int crc(int fd, u_long * cval, u_long * clen);
|
extern int crc(int fd, uint32_t *cval, off_t *clen);
|
||||||
|
|
||||||
#define DISTMD5 1 /* MD5 format */
|
#define DISTMD5 1 /* MD5 format */
|
||||||
#define DISTINF 2 /* .inf format */
|
#define DISTINF 2 /* .inf format */
|
||||||
@ -267,7 +269,10 @@ chkinf(FILE * fp, const char *path)
|
|||||||
char ext[3];
|
char ext[3];
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
const char *dname;
|
const char *dname;
|
||||||
u_long sum, len, chk;
|
off_t len;
|
||||||
|
u_long sum;
|
||||||
|
intmax_t sumlen;
|
||||||
|
uint32_t chk;
|
||||||
int rval, error, c, pieces, cnt, fd;
|
int rval, error, c, pieces, cnt, fd;
|
||||||
char ch;
|
char ch;
|
||||||
|
|
||||||
@ -280,8 +285,8 @@ chkinf(FILE * fp, const char *path)
|
|||||||
if ((c = sscanf(buf, "Pieces = %d%c", &pieces, &ch)) != 2 ||
|
if ((c = sscanf(buf, "Pieces = %d%c", &pieces, &ch)) != 2 ||
|
||||||
ch != '\n' || pieces < 1)
|
ch != '\n' || pieces < 1)
|
||||||
error = E_BADINF;
|
error = E_BADINF;
|
||||||
} else if (((c = sscanf(buf, "cksum.%2s = %lu %lu%c", ext, &sum,
|
} else if (((c = sscanf(buf, "cksum.%2s = %lu %jd%c", ext, &sum,
|
||||||
&len, &ch)) != 4 &&
|
&sumlen, &ch)) != 4 &&
|
||||||
(!feof(fp) || c != 3)) || (c == 4 && ch != '\n') ||
|
(!feof(fp) || c != 3)) || (c == 4 && ch != '\n') ||
|
||||||
ext[0] != 'a' + cnt / 26 || ext[1] != 'a' + cnt % 26)
|
ext[0] != 'a' + cnt / 26 || ext[1] != 'a' + cnt % 26)
|
||||||
error = E_BADINF;
|
error = E_BADINF;
|
||||||
@ -292,7 +297,7 @@ chkinf(FILE * fp, const char *path)
|
|||||||
error = E_ERRNO;
|
error = E_ERRNO;
|
||||||
else if (fstat(fd, &sb))
|
else if (fstat(fd, &sb))
|
||||||
error = E_ERRNO;
|
error = E_ERRNO;
|
||||||
else if (sb.st_size != (off_t)len)
|
else if (sb.st_size != (off_t)sumlen)
|
||||||
error = E_LENGTH;
|
error = E_LENGTH;
|
||||||
else if (!opt_exist) {
|
else if (!opt_exist) {
|
||||||
if (crc(fd, &chk, &len))
|
if (crc(fd, &chk, &len))
|
||||||
|
Loading…
Reference in New Issue
Block a user