PERFORCE change 178387 for review
Garrett Cooper
gcooper at FreeBSD.org
Mon May 17 11:00:43 UTC 2010
http://p4web.freebsd.org/@@178387?ac=10
Change 178387 by gcooper at gcooper-bayonetta on 2010/05/17 10:59:57
The semantic of PASS / FAIL has multiple meanings with multiple C apis,
so let's use the appropriate return codes instead.
Affected files ...
.. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/lib/libpkg/file.c#15 edit
.. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/lib/libpkg/match.c#2 edit
.. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/lib/libpkg/pen.c#3 edit
.. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/lib/libpkg/pkg.h#9 edit
.. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/lib/libpkg/plist.c#4 edit
.. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/add/extract.c#4 edit
.. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/add/futil.c#7 edit
.. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/add/perform.c#12 edit
.. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/create/perform.c#28 edit
.. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/delete/perform.c#6 edit
.. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/info/perform.c#7 edit
.. //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/version/perform.c#11 edit
Differences ...
==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/lib/libpkg/file.c#15 (text+ko) ====
@@ -51,9 +51,9 @@
{
struct stat sb;
- if (lstat(fname, &sb) != FAIL && S_ISDIR(sb.st_mode))
+ if (lstat(fname, &sb) == 0 && S_ISDIR(sb.st_mode))
return TRUE;
- else if (lstat(strconcat(fname, "/."), &sb) != FAIL && S_ISDIR(sb.st_mode))
+ else if (lstat(strconcat(fname, "/."), &sb) == 0 && S_ISDIR(sb.st_mode))
return TRUE;
else
return FALSE;
@@ -90,7 +90,7 @@
isfile(const char *fname)
{
struct stat sb;
- if (stat(fname, &sb) != FAIL && S_ISREG(sb.st_mode))
+ if (stat(fname, &sb) == 0 && S_ISREG(sb.st_mode))
return TRUE;
return FALSE;
}
@@ -104,7 +104,7 @@
isemptyfile(const char *fname)
{
struct stat sb;
- if (stat(fname, &sb) != FAIL && S_ISREG(sb.st_mode)) {
+ if (stat(fname, &sb) == 0 && S_ISREG(sb.st_mode)) {
if (sb.st_size != 0)
return FALSE;
}
@@ -116,7 +116,7 @@
issymlink(const char *fname)
{
struct stat sb;
- if (lstat(fname, &sb) != FAIL && S_ISLNK(sb.st_mode))
+ if (lstat(fname, &sb) == 0 && S_ISLNK(sb.st_mode))
return TRUE;
return FALSE;
}
@@ -199,7 +199,7 @@
char *contents = NULL;
int fd = -1;
- if (stat(fname, &sb) == FAIL) {
+ if (stat(fname, &sb) == -1) {
warn("%s: can't stat '%s'", __func__, fname);
} else {
contents = (char *)malloc(sb.st_size + 1);
==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/lib/libpkg/match.c#2 (text+ko) ====
@@ -379,14 +379,14 @@
asprintf(&buf, "%s/%s", LOG_DIR, name);
if (buf == NULL)
goto errout;
- if (!isdir(buf) || access(buf, R_OK) == FAIL) {
+ if (!isdir(buf) || access(buf, R_OK) == -1) {
result = 0;
} else {
asprintf(&buf2, "%s/%s", buf, CONTENTS_FNAME);
if (buf2 == NULL)
goto errout;
- if (!isfile(buf2) || access(buf2, R_OK) == FAIL)
+ if (!isfile(buf2) || access(buf2, R_OK) == -1)
result = -1;
else
result = 1;
==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/lib/libpkg/pen.c#3 (text+ko) ====
@@ -61,7 +61,7 @@
else if (stat("/tmp", &sb) == 0 && min_free("/tmp") >= sz)
strcpy(pen, "/tmp/instmp.XXXXXX");
else if ((stat("/usr/tmp", &sb) == 0 ||
- mkdir("/usr/tmp", 01777) == SUCCESS) && min_free("/usr/tmp") >= sz)
+ mkdir("/usr/tmp", 01777) == 0) && min_free("/usr/tmp") >= sz)
strcpy(pen, "/usr/tmp/instmp.XXXXXX");
else {
errno = ENOSPC;
==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/lib/libpkg/pkg.h#9 (text+ko) ====
@@ -42,8 +42,6 @@
#include <unistd.h>
/* Macros */
-#define SUCCESS (0)
-#define FAIL (-1)
#ifndef TRUE
#define TRUE (1)
==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/lib/libpkg/plist.c#4 (text+ko) ====
@@ -257,7 +257,7 @@
else if (!strcmp(cmd, "option"))
return PLIST_OPTION;
else
- return FAIL;
+ return -1;
}
/* Read a packing list from a file */
@@ -289,7 +289,7 @@
goto bottom;
}
cmd = plist_cmd(pline + 1, &cp);
- if (cmd == FAIL) {
+ if (cmd == -1) {
warnx("%s: unknown command '%s' (package tools out of "
"date?)", __func__, pline);
goto bottom;
@@ -299,7 +299,7 @@
if (cmd == PLIST_PKGDEP) {
warnx("corrupted record (pkgdep line without "
"argument), ignoring");
- cmd = FAIL;
+ cmd = -1;
}
goto bottom;
}
@@ -459,7 +459,7 @@
{
PackingList p;
const char *Where = ".", *last_file = "";
- Boolean fail = SUCCESS;
+ Boolean fail = FALSE;
Boolean preserve;
char tmp[FILENAME_MAX], *name = NULL;
char *prefix = NULL;
@@ -489,7 +489,7 @@
printf("Execute '%s'\n", tmp);
if (!Fake && system(tmp)) {
warnx("unexec command for '%s' failed", tmp);
- fail = FAIL;
+ fail = -1;
}
break;
@@ -524,7 +524,7 @@
warnx("'%s' fails original MD5 checksum - %s",
tmp, Force ? "deleted anyway." : "not deleted.");
if (!Force) {
- fail = FAIL;
+ fail = -1;
continue;
}
}
@@ -534,7 +534,7 @@
printf("Delete file %s\n", tmp);
if (!Fake) {
if (delete_hierarchy(tmp, ign_err, nukedirs))
- fail = FAIL;
+ fail = -1;
if (preserve && name) {
char tmp2[FILENAME_MAX];
@@ -561,7 +561,7 @@
printf("Delete directory %s\n", tmp);
if (!Fake && delete_hierarchy(tmp, ign_err, FALSE)) {
warnx("unable to completely remove directory '%s'", tmp);
- fail = FAIL;
+ fail = -1;
}
}
last_file = p->name;
==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/add/extract.c#4 (text+ko) ====
@@ -226,7 +226,7 @@
printf("extract: CWD to %s\n", p->name);
PUSHOUT(Directory);
if (strcmp(p->name, ".")) {
- if (!Fake && make_hierarchy(p->name) == FAIL) {
+ if (!Fake && make_hierarchy(p->name) == -1) {
cleanup(0);
errx(2, "%s: unable to cwd to '%s'", __func__, p->name);
}
==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/add/futil.c#7 (text+ko) ====
@@ -46,14 +46,14 @@
if (!isdir(dir)) {
if (cp2)
*cp2 = '/';
- return FAIL;
+ return -1;
}
}
else {
if (mkdir(dir, 0777) < 0) {
if (cp2)
*cp2 = '/';
- return FAIL;
+ return -1;
}
apply_perms(NULL, dir);
}
@@ -63,7 +63,7 @@
cp1 = cp2 + 1;
}
}
- return SUCCESS;
+ return 0;
}
/* Using permission defaults, apply them as necessary */
==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/add/perform.c#12 (text+ko) ====
@@ -94,7 +94,7 @@
if (!pkg) {
fgets(playpen, FILENAME_MAX, stdin);
playpen[strlen(playpen) - 1] = '\0'; /* pesky newline! */
- if (chdir(playpen) == FAIL) {
+ if (chdir(playpen) == -1) {
warnx("pkg_add in SLAVE mode can't chdir to %s", playpen);
return 1;
}
@@ -135,7 +135,7 @@
extract_whole_archive_from_stdin = TRUE;
sb.st_size = 100000; /* Make up a plausible average size */
} else {
- if (stat(pkg, &sb) == FAIL) {
+ if (stat(pkg, &sb) == -1) {
warnx("can't stat package file '%s'", pkg);
goto bomb;
}
==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/create/perform.c#28 (text+ko) ====
@@ -853,7 +853,7 @@
return FALSE;
}
getcwd(homedir, sizeof(homedir));
- if (chdir(log_dir) == FAIL) {
+ if (chdir(log_dir) == -1) {
warnx("can't change directory to '%s'!", log_dir);
return FALSE;
}
@@ -883,7 +883,7 @@
make_dist(homedir, pkg, suf, &plist);
free_plist(&plist);
- if (chdir(homedir) == FAIL) {
+ if (chdir(homedir) == -1) {
warnx("can't change directory to '%s'!", homedir);
return FALSE;
}
==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/delete/perform.c#6 (text+ko) ====
@@ -172,7 +172,7 @@
errx(2, "%s: unable to get current working directory!", __func__);
}
- if (chdir(LogDir) == FAIL) {
+ if (chdir(LogDir) == -1) {
warnx("unable to change directory to %s! deinstall failed", LogDir);
return 1;
}
@@ -313,7 +313,7 @@
}
}
- if (chdir(home) == FAIL) {
+ if (chdir(home) == -1) {
cleanup(0);
errx(2, "%s: unable to return to working directory %s!", __func__,
home);
@@ -323,12 +323,12 @@
* Some packages aren't packed right, so we need to just ignore
* delete_package()'s status. Ugh! :-(
*/
- if (delete_package(FALSE, CleanDirs, &Plist) == FAIL)
+ if (delete_package(FALSE, CleanDirs, &Plist) == -1)
warnx(
"couldn't entirely delete package (perhaps the packing list is\n"
"incorrectly specified?)");
- if (chdir(LogDir) == FAIL) {
+ if (chdir(LogDir) == -1) {
warnx("unable to change directory to %s! deinstall failed", LogDir);
return 1;
}
@@ -348,7 +348,7 @@
}
}
- if (chdir(home) == FAIL) {
+ if (chdir(home) == -1) {
cleanup(0);
errx(2, "%s: unable to return to working directory %s!", __func__,
home);
@@ -409,7 +409,7 @@
STAILQ_FOREACH(rb_entry, rb_list, link)
if (strcmp(rb_entry->pkgname, pkgname)) /* no match */
fputs(rb_entry->pkgname, fpwr), putc('\n', fpwr);
- if (fchmod(s, 0644) == FAIL) {
+ if (fchmod(s, 0644) == -1) {
warnx("error changing permission of temp file '%s'", ftmp);
fclose(fpwr);
goto cleanexit;
==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/info/perform.c#7 (text+ko) ====
@@ -136,7 +136,7 @@
* compress an average of 75%, but we're only unpacking the + files
* to be very optimistic.
*/
- if (stat(fname, &sb) == FAIL) {
+ if (stat(fname, &sb) == -1) {
warnx("can't stat package file '%s'", fname);
code = 1;
goto bail;
@@ -166,7 +166,7 @@
return 1;
}
sprintf(log_dir, "%s/%s", LOG_DIR, pkg);
- if (chdir(log_dir) == FAIL) {
+ if (chdir(log_dir) == -1) {
warnx("can't change directory to '%s'!", log_dir);
return 1;
}
==== //depot/projects/soc2007/gcooper-pkg_install-enhancements-simplified/usr.sbin/pkg_install/version/perform.c#11 (text+ko) ====
@@ -176,7 +176,7 @@
*/
if (plist.origin != NULL && !UseINDEXOnly) {
snprintf(tmp, PATH_MAX, "%s/%s", PORTS_DIR, plist.origin);
- if (isdir(tmp) && chdir(tmp) != FAIL && isfile("Makefile")) {
+ if (isdir(tmp) && chdir(tmp) == 0 && isfile("Makefile")) {
if ((latest = vpipe("/usr/bin/make -V PKGNAME", tmp)) == NULL)
warnx("Failed to get PKGNAME from %s/Makefile!", tmp);
else
More information about the p4-projects
mailing list