o Don't leak fd on error.
o parselength() returns 0 or -1 so int is enough for its return type. Submitted by: Ighighi Ighighi, sheldonh MFC after: 3 weeks
This commit is contained in:
parent
3da8df6081
commit
a39846b5e4
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=162412
@ -40,7 +40,7 @@ static const char rcsid[] =
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static off_t parselength(char *, off_t *);
|
||||
static int parselength(char *, off_t *);
|
||||
static void usage(void);
|
||||
|
||||
static int no_create;
|
||||
@ -108,6 +108,8 @@ main(int argc, char **argv)
|
||||
omode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
|
||||
|
||||
while ((fname = *argv++) != NULL) {
|
||||
if (fd != -1)
|
||||
close(fd);
|
||||
if ((fd = open(fname, oflags, omode)) == -1) {
|
||||
if (errno != ENOENT) {
|
||||
warn("%s", fname);
|
||||
@ -138,9 +140,9 @@ main(int argc, char **argv)
|
||||
error++;
|
||||
continue;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
}
|
||||
if (fd != -1)
|
||||
close(fd);
|
||||
|
||||
return error ? EXIT_FAILURE : EXIT_SUCCESS;
|
||||
}
|
||||
@ -149,7 +151,7 @@ main(int argc, char **argv)
|
||||
* Return the numeric value of a string given in the form [+-][0-9]+[GMKT]
|
||||
* or -1 on format error or overflow.
|
||||
*/
|
||||
static off_t
|
||||
static int
|
||||
parselength(char *ls, off_t *sz)
|
||||
{
|
||||
off_t length, oflow;
|
||||
|
Loading…
Reference in New Issue
Block a user