Thread View: gnu.utils.bug
2 messages
2 total messages
Started by Chris Hanson
Thu, 08 Feb 1990 18:52
minor changes for fileutils-1.0 under hp-ux
Author: Chris Hanson
Date: Thu, 08 Feb 1990 18:52
Date: Thu, 08 Feb 1990 18:52
78 lines
2715 bytes
2715 bytes
The following simple changes to "cp.c" and "mv.c" improve these
programs when used under hp-ux. The programs work fine without the
changes, but they work better with them.
*** cp.c.~1~ Sat Feb 3 13:47:13 1990
--- cp.c Thu Feb 8 13:44:08 1990
***************
*** 160,166 ****
egid = getegid ();
ngroups = 1;
groups = (int *) xmalloc (ngroups * sizeof *groups);
! #ifdef USG
*groups = getgid ();
#else
for (;;)
--- 160,166 ----
egid = getegid ();
ngroups = 1;
groups = (int *) xmalloc (ngroups * sizeof *groups);
! #if defined(USG) && !defined(hpux)
*groups = getgid ();
#else
for (;;)
***************
*** 748,754 ****
/* ??? Since USG doesn't have ftruncate, this can't be done.
This should be fixed. */
! #ifndef USG
if (write (target_desc, "", 1) != 1
|| ftruncate (target_desc, n_read_total) < 0)
error ("cannot write", errno, dst_path, FATAL);
--- 748,754 ----
/* ??? Since USG doesn't have ftruncate, this can't be done.
This should be fixed. */
! #if !defined(USG) || defined(hpux)
if (write (target_desc, "", 1) != 1
|| ftruncate (target_desc, n_read_total) < 0)
error ("cannot write", errno, dst_path, FATAL);
*** mv.c.~1~ Fri Feb 2 22:57:45 1990
--- mv.c Thu Feb 8 13:44:07 1990
***************
*** 91,97 ****
return (stat (fn, &stb) >= 0 && (stb.st_mode & S_IFMT) == S_IFDIR);
}
! #ifdef USG
int
rename (from, to)
--- 91,97 ----
return (stat (fn, &stb) >= 0 && (stb.st_mode & S_IFMT) == S_IFDIR);
}
! #if defined(USG) && !defined(hpux)
int
rename (from, to)
***************
*** 311,317 ****
error (0, errno, "cannot create `%s'", to);
return;
}
! #ifdef USG
chmod (to, stbf.st_mode & 0777); /* again, can't fail */
#else
fchmod (ofd, stbf.st_mode & 0777); /* again, can't fail */
--- 311,317 ----
error (0, errno, "cannot create `%s'", to);
return;
}
! #if defined(USG) && !defined(hpux)
chmod (to, stbf.st_mode & 0777); /* again, can't fail */
#else
fchmod (ofd, stbf.st_mode & 0777); /* again, can't fail */
"can't fail"
Author: John Gilmore
Date: Mon, 12 Feb 1990 09:23
Date: Mon, 12 Feb 1990 09:23
23 lines
1354 bytes
1354 bytes
In a code fragment posted as part of a misguided hp-ux patch
(add #ifdef hpux everywhere ifdef USG already was -- ecch)
I found the following code from cp.c:
> #ifdef USG
> chmod (to, stbf.st_mode & 0777); /* again, can't fail */
> #else
> fchmod (ofd, stbf.st_mode & 0777); /* again, can't fail */
What does "can't fail" mean in this context? Does it mean that if
it *does* fail, we will not detect the problem? Does it mean that
the program has no bugs? No, it means that the programmer was lazy.
At best it means the programmer had no imagination. I can think of
ways to make this fail.
ERROR RETURNS FROM SYSTEM CALLS MUST ALWAYS BE CHECKED!
If the rest of the file utils are written like this, they need some
work before it can be claimed that they are 'better' than the Unix
versions they're intended to replace.
--
John Gilmore {sun,pacbell,uunet,pyramid}!hoptoad!gnu gnu@toad.com
Just say *yes* to drugs. If someone offers you a drug war, just say no.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads