PERFORCE change 131204 for review
John Birrell
jb at FreeBSD.org
Tue Dec 18 19:17:22 PST 2007
http://perforce.freebsd.org/chv.cgi?CH=131204
Change 131204 by jb at jb_freebsd1 on 2007/12/19 03:17:12
getopt(3) returns an integer. Even on Solaris.
The use of EOF is inappropriate. getopt(3) returns nothing associated
with a stream file.
On FreeBSD/arm, char is unsigned, so using the wrong variable type
cases a valid compiler warning.
This is a good example of why all code should compile cleanly.
Affected files ...
.. //depot/projects/dtrace/src/contrib/opensolaris/cmd/dtrace/dtrace.c#11 edit
Differences ...
==== //depot/projects/dtrace/src/contrib/opensolaris/cmd/dtrace/dtrace.c#11 (text) ====
@@ -1202,8 +1202,8 @@
g_ofp = stdout;
int done = 0, mode = 0;
- int err, i;
- char c, *p, **v;
+ int err, i, c;
+ char *p, **v;
struct ps_prochandle *P;
pid_t pid;
@@ -1230,7 +1230,7 @@
* options into g_argv[], and abort if any invalid options are found.
*/
for (optind = 1; optind < argc; optind++) {
- while ((c = getopt(argc, argv, DTRACE_OPTSTR)) != EOF) {
+ while ((c = getopt(argc, argv, DTRACE_OPTSTR)) != -1) {
switch (c) {
case '3':
if (strcmp(optarg, "2") != 0) {
@@ -1413,7 +1413,7 @@
* this time; these will compiled as part of the fourth processing pass.
*/
for (optind = 1; optind < argc; optind++) {
- while ((c = getopt(argc, argv, DTRACE_OPTSTR)) != EOF) {
+ while ((c = getopt(argc, argv, DTRACE_OPTSTR)) != -1) {
switch (c) {
case 'a':
if (dtrace_setopt(g_dtp, "grabanon", 0) != 0)
@@ -1570,7 +1570,7 @@
* may been affected by any library options set by the second pass.
*/
for (optind = 1; optind < argc; optind++) {
- while ((c = getopt(argc, argv, DTRACE_OPTSTR)) != EOF) {
+ while ((c = getopt(argc, argv, DTRACE_OPTSTR)) != -1) {
switch (c) {
case 'c':
if ((v = make_argv(optarg)) == NULL)
More information about the p4-projects
mailing list