[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
cleanup for pax
- To: tech_(_at_)_openbsd_(_dot_)_org
- Subject: cleanup for pax
- From: Han Boetes <han_(_at_)_mijncomputer_(_dot_)_nl>
- Date: Mon, 6 Feb 2006 21:51:01 +0100
- Mail-followup-to: tech_(_at_)_openbsd_(_dot_)_org
While porting pax to another platform I ran into a few minor
issues. I think the ones included in this patch are worth sending
back to the OpenBSD team.
- Remove support for LONG_OFF_T, required for BSD4.4.
- Replace ftree_add(str, NULL); with ftree_add(str, 0);
This goes right because NULL is defined to 0, but it should be
0, not NULL.
- Initialise *dir = NULL twice to make gcc happy.
Please verify if this is the right initialisation, since I
don't actually understand the code.
Index: Makefile
===================================================================
RCS file: /cvs/src/bin/pax/Makefile,v
retrieving revision 1.10
diff -u -p -r1.10 Makefile
--- Makefile 26 May 2001 00:32:20 -0000 1.10
+++ Makefile 6 Feb 2006 20:43:14 -0000
@@ -1,16 +1,5 @@
# $OpenBSD: Makefile,v 1.10 2001/05/26 00:32:20 millert Exp $
-# To install on versions prior to BSD 4.4 the following may have to be
-# defined with CFLAGS +=
-#
-# -DLONG_OFF_T Define this if the base type of an off_t is a long (and is
-# NOT a quad). (This is often defined in the file
-# /usr/include/sys/types.h).
-# This define is important, as if you do have a quad_t
-# off_t and define LONG_OFF_T, pax will compile but will
-# NOT RUN PROPERLY.
-#
-
PROG= pax
SRCS= ar_io.c ar_subs.c buf_subs.c cache.c cpio.c file_subs.c ftree.c\
gen_subs.c getoldopt.c options.c pat_rep.c pax.c sel_subs.c tables.c\
Index: ar_io.c
===================================================================
RCS file: /cvs/src/bin/pax/ar_io.c,v
retrieving revision 1.37
diff -u -p -r1.37 ar_io.c
--- ar_io.c 4 Aug 2005 10:02:44 -0000 1.37
+++ ar_io.c 6 Feb 2006 20:43:15 -0000
@@ -388,11 +388,7 @@ ar_close(void)
* could have written anything yet.
*/
if (frmt == NULL) {
-# ifdef LONG_OFF_T
- (void)fprintf(listf, "%s: unknown format, %lu bytes skipped.\n",
-# else
(void)fprintf(listf, "%s: unknown format, %qu bytes skipped.\n",
-# endif
argv0, rdcnt);
(void)fflush(listf);
flcnt = 0;
@@ -403,11 +399,7 @@ ar_close(void)
(void)fprintf(listf, "%qu blocks\n", (rdcnt ? rdcnt : wrcnt) / 5120);
else if (strcmp(NM_TAR, argv0) != 0)
(void)fprintf(listf,
-# ifdef LONG_OFF_T
- "%s: %s vol %d, %lu files, %lu bytes read, %lu bytes written.\n",
-# else
"%s: %s vol %d, %lu files, %qu bytes read, %qu bytes written.\n",
-# endif
argv0, frmt->name, arvol-1, flcnt, rdcnt, wrcnt);
(void)fflush(listf);
flcnt = 0;
Index: cpio.c
===================================================================
RCS file: /cvs/src/bin/pax/cpio.c,v
retrieving revision 1.17
diff -u -p -r1.17 cpio.c
--- cpio.c 16 Apr 2004 22:50:23 -0000 1.17
+++ cpio.c 6 Feb 2006 20:43:15 -0000
@@ -219,13 +219,8 @@ rd_ln_nm(ARCHD *arcn)
*/
if ((arcn->sb.st_size == 0) ||
(arcn->sb.st_size >= sizeof(arcn->ln_name))) {
-# ifdef LONG_OFF_T
- paxwarn(1, "Cpio link name length is invalid: %lu",
- arcn->sb.st_size);
-# else
paxwarn(1, "Cpio link name length is invalid: %qu",
arcn->sb.st_size);
-# endif
return(-1);
}
@@ -308,13 +303,8 @@ cpio_rd(ARCHD *arcn, char *buf)
arcn->sb.st_mtime = (time_t)asc_ul(hd->c_mtime, sizeof(hd->c_mtime),
OCT);
arcn->sb.st_ctime = arcn->sb.st_atime = arcn->sb.st_mtime;
-# ifdef LONG_OFF_T
- arcn->sb.st_size = (off_t)asc_ul(hd->c_filesize,sizeof(hd->c_filesize),
- OCT);
-# else
arcn->sb.st_size = (off_t)asc_uqd(hd->c_filesize,sizeof(hd->c_filesize),
OCT);
-# endif
/*
* check name size and if valid, read in the name of this entry (name
@@ -409,13 +399,8 @@ cpio_wr(ARCHD *arcn)
/*
* set data size for file data
*/
-# ifdef LONG_OFF_T
- if (ul_asc((u_long)arcn->sb.st_size, hd->c_filesize,
- sizeof(hd->c_filesize), OCT)) {
-# else
if (uqd_asc((u_quad_t)arcn->sb.st_size, hd->c_filesize,
sizeof(hd->c_filesize), OCT)) {
-# endif
paxwarn(1,"File is too large for cpio format %s",
arcn->org_name);
return(1);
@@ -593,13 +578,8 @@ vcpio_rd(ARCHD *arcn, char *buf)
arcn->sb.st_gid = (gid_t)asc_ul(hd->c_gid, sizeof(hd->c_gid), HEX);
arcn->sb.st_mtime = (time_t)asc_ul(hd->c_mtime,sizeof(hd->c_mtime),HEX);
arcn->sb.st_ctime = arcn->sb.st_atime = arcn->sb.st_mtime;
-# ifdef LONG_OFF_T
- arcn->sb.st_size = (off_t)asc_ul(hd->c_filesize,
- sizeof(hd->c_filesize), HEX);
-# else
arcn->sb.st_size = (off_t)asc_uqd(hd->c_filesize,
sizeof(hd->c_filesize), HEX);
-# endif
arcn->sb.st_nlink = (nlink_t)asc_ul(hd->c_nlink, sizeof(hd->c_nlink),
HEX);
devmajor = (dev_t)asc_ul(hd->c_maj, sizeof(hd->c_maj), HEX);
@@ -734,13 +714,8 @@ vcpio_wr(ARCHD *arcn)
* much to pad.
*/
arcn->pad = VCPIO_PAD(arcn->sb.st_size);
-# ifdef LONG_OFF_T
- if (ul_asc((u_long)arcn->sb.st_size, hd->c_filesize,
- sizeof(hd->c_filesize), HEX)) {
-# else
if (uqd_asc((u_quad_t)arcn->sb.st_size, hd->c_filesize,
sizeof(hd->c_filesize), HEX)) {
-# endif
paxwarn(1,"File is too large for sv4cpio format %s",
arcn->org_name);
return(1);
Index: extern.h
===================================================================
RCS file: /cvs/src/bin/pax/extern.h,v
retrieving revision 1.31
diff -u -p -r1.31 extern.h
--- extern.h 28 Apr 2005 06:58:07 -0000 1.31
+++ extern.h 6 Feb 2006 20:43:15 -0000
@@ -173,10 +173,8 @@ void ls_tty(ARCHD *);
void safe_print(const char *, FILE *);
u_long asc_ul(char *, int, int);
int ul_asc(u_long, char *, int, int);
-#ifndef LONG_OFF_T
u_quad_t asc_uqd(char *, int, int);
int uqd_asc(u_quad_t, char *, int, int);
-#endif
size_t fieldcpy(char *, size_t, const char *, size_t);
/*
Index: gen_subs.c
===================================================================
RCS file: /cvs/src/bin/pax/gen_subs.c,v
retrieving revision 1.18
diff -u -p -r1.18 gen_subs.c
--- gen_subs.c 28 Apr 2005 06:58:07 -0000 1.18
+++ gen_subs.c 6 Feb 2006 20:43:15 -0000
@@ -130,18 +130,10 @@ ls_list(ARCHD *arcn, time_t now, FILE *f
* print device id's for devices, or sizes for other nodes
*/
if ((arcn->type == PAX_CHR) || (arcn->type == PAX_BLK))
-# ifdef LONG_OFF_T
- (void)fprintf(fp, "%4u,%4u ", MAJOR(sbp->st_rdev),
-# else
(void)fprintf(fp, "%4lu,%4lu ", (unsigned long)MAJOR(sbp->st_rdev),
-# endif
(unsigned long)MINOR(sbp->st_rdev));
else {
-# ifdef LONG_OFF_T
- (void)fprintf(fp, "%9lu ", sbp->st_size);
-# else
(void)fprintf(fp, "%9qu ", sbp->st_size);
-# endif
}
/*
@@ -311,7 +303,6 @@ ul_asc(u_long val, char *str, int len, i
return(0);
}
-#ifndef LONG_OFF_T
/*
* asc_uqd()
* convert hex/octal character string into a u_quad_t. We do not have to
@@ -407,7 +398,6 @@ uqd_asc(u_quad_t val, char *str, int len
return(-1);
return(0);
}
-#endif
/*
* Copy at max min(bufz, fieldsz) chars from field to buf, stopping
Index: options.c
===================================================================
RCS file: /cvs/src/bin/pax/options.c,v
retrieving revision 1.63
diff -u -p -r1.63 options.c
--- options.c 2 Jun 2005 19:11:06 -0000 1.63
+++ options.c 6 Feb 2006 20:43:16 -0000
@@ -831,7 +831,7 @@ tar_options(int argc, char **argv)
default:
{
int sawpat = 0;
- char *file, *dir;
+ char *file, *dir = NULL;
while (nincfiles || *argv != NULL) {
/*
@@ -905,7 +905,7 @@ tar_options(int argc, char **argv)
}
while (nincfiles || *argv != NULL) {
- char *file, *dir;
+ char *file, *dir = NULL;
/*
* If we queued up any include files, pull them in
@@ -1256,7 +1256,7 @@ cpio_options(int argc, char **argv)
*/
maxflt = 0;
while ((str = getline(stdin)) != NULL) {
- ftree_add(str, NULL);
+ ftree_add(str, 0);
}
if (getline_error) {
paxwarn(1, "Problem while reading stdin");
@@ -1505,7 +1505,7 @@ getline(FILE *f)
temp[len-1] = 0;
return(temp);
}
-
+
/*
* no_op()
* for those option functions where the archive format has nothing to do.
Index: tar.c
===================================================================
RCS file: /cvs/src/bin/pax/tar.c,v
retrieving revision 1.40
diff -u -p -r1.40 tar.c
--- tar.c 17 Dec 2005 19:47:02 -0000 1.40
+++ tar.c 6 Feb 2006 20:43:16 -0000
@@ -62,9 +62,7 @@ static size_t expandname(char *, size_t,
static u_long tar_chksm(char *, int);
static char *name_split(char *, int);
static int ul_oct(u_long, char *, int, int);
-#ifndef LONG_OFF_T
static int uqd_oct(u_quad_t, char *, int, int);
-#endif
static uid_t uid_nobody;
static uid_t uid_warn;
@@ -202,7 +200,6 @@ ul_oct(u_long val, char *str, int len, i
return(0);
}
-#ifndef LONG_OFF_T
/*
* uqd_oct()
* convert an u_quad_t to an octal string. one of many oddball field
@@ -256,7 +253,6 @@ uqd_oct(u_quad_t val, char *str, int len
return(-1);
return(0);
}
-#endif
/*
* tar_chksm()
@@ -410,11 +406,7 @@ tar_rd(ARCHD *arcn, char *buf)
0xfff);
arcn->sb.st_uid = (uid_t)asc_ul(hd->uid, sizeof(hd->uid), OCT);
arcn->sb.st_gid = (gid_t)asc_ul(hd->gid, sizeof(hd->gid), OCT);
-#ifdef LONG_OFF_T
- arcn->sb.st_size = (off_t)asc_ul(hd->size, sizeof(hd->size), OCT);
-#else
arcn->sb.st_size = (off_t)asc_uqd(hd->size, sizeof(hd->size), OCT);
-#endif
arcn->sb.st_mtime = (time_t)asc_ul(hd->mtime, sizeof(hd->mtime), OCT);
arcn->sb.st_ctime = arcn->sb.st_atime = arcn->sb.st_mtime;
@@ -621,13 +613,8 @@ tar_wr(ARCHD *arcn)
* data follows this file, so set the pad
*/
hd->linkflag = AREGTYPE;
-# ifdef LONG_OFF_T
- if (ul_oct((u_long)arcn->sb.st_size, hd->size,
- sizeof(hd->size), 1)) {
-# else
if (uqd_oct((u_quad_t)arcn->sb.st_size, hd->size,
sizeof(hd->size), 1)) {
-# endif
paxwarn(1,"File is too large for tar %s", arcn->org_name);
return(1);
}
@@ -788,11 +775,7 @@ ustar_rd(ARCHD *arcn, char *buf)
*/
arcn->sb.st_mode = (mode_t)(asc_ul(hd->mode, sizeof(hd->mode), OCT) &
0xfff);
-#ifdef LONG_OFF_T
- arcn->sb.st_size = (off_t)asc_ul(hd->size, sizeof(hd->size), OCT);
-#else
arcn->sb.st_size = (off_t)asc_uqd(hd->size, sizeof(hd->size), OCT);
-#endif
arcn->sb.st_mtime = (time_t)asc_ul(hd->mtime, sizeof(hd->mtime), OCT);
arcn->sb.st_ctime = arcn->sb.st_atime = arcn->sb.st_mtime;
@@ -1018,13 +1001,8 @@ ustar_wr(ARCHD *arcn)
else
hd->typeflag = REGTYPE;
arcn->pad = TAR_PAD(arcn->sb.st_size);
-# ifdef LONG_OFF_T
- if (ul_oct((u_long)arcn->sb.st_size, hd->size,
- sizeof(hd->size), 3)) {
-# else
if (uqd_oct((u_quad_t)arcn->sb.st_size, hd->size,
sizeof(hd->size), 3)) {
-# endif
paxwarn(1,"File is too long for ustar %s",arcn->org_name);
return(1);
}
# Han
Visit your host, monkey.org