From: Tomas Hruby Date: Mon, 10 May 2010 13:26:00 +0000 (+0000) Subject: Use of all NIL_* defines converted to NULL X-Git-Tag: v3.1.7~71 X-Git-Url: http://zhaoyanbai.com/repos/%7B%24global.css%7D?a=commitdiff_plain;h=6e25ad8b0a5606fc9351824adf9034d2ef7f7293;p=minix.git Use of all NIL_* defines converted to NULL --- diff --git a/commands/aal/archiver.c b/commands/aal/archiver.c index 797f5ce11..b7e8da46b 100644 --- a/commands/aal/archiver.c +++ b/commands/aal/archiver.c @@ -25,6 +25,7 @@ static char RcsId[] = "$Header$"; #endif */ +#include #include #include #ifndef S_IREAD @@ -47,7 +48,6 @@ struct ranlib *tab; unsigned int tnum = 0; char *tstrtab; unsigned int tssiz = 0; -char *malloc(), *realloc(), *strcpy(), *strncpy(); long time(); unsigned int tabsz, strtabsz; #else @@ -68,10 +68,6 @@ typedef char BOOL; #define MEMBER struct ar_hdr -#define NIL_PTR ((char *) 0) -#define NIL_MEM ((MEMBER *) 0) -#define NIL_LONG ((long *) 0) - #define IO_SIZE (10 * 1024) #define equal(str1, str2) (!strncmp((str1), (str2), 14)) @@ -136,14 +132,14 @@ char *basename(path) char *path; { register char *ptr = path; - register char *last = NIL_PTR; + register char *last = NULL; while (*ptr != '\0') { if (*ptr == '/') last = ptr; ptr++; } - if (last == NIL_PTR) + if (last == NULL) return path; if (*(last + 1) == '\0') { *last = '\0'; @@ -302,7 +298,7 @@ get_member() again: if (rd_arhdr(ar_fd, &member) == 0) - return NIL_MEM; + return NULL; if (member.ar_size < 0) { error(TRUE, "archive has member with negative size\n"); } @@ -332,7 +328,7 @@ register char *argv[]; #endif ) temp_fd = open_archive(temp_arch, CREATE); - while ((member = get_member()) != NIL_MEM) { + while ((member = get_member()) != NULL) { if (argc > 3) { for (i = 3; i < argc; i++) { if (equal(basename(argv[i]), member->ar_name)) diff --git a/commands/ibm/dosread.c b/commands/ibm/dosread.c index 6496980a9..a2d87a22e 100644 --- a/commands/ibm/dosread.c +++ b/commands/ibm/dosread.c @@ -52,7 +52,6 @@ typedef struct dir_entry DIRECTORY; #define DIR 0x2E #define DIR_SIZE (sizeof (struct dir_entry)) #define SUB_DIR 0x10 -#define NIL_DIR ((DIRECTORY *) 0) #define LAST_CLUSTER12 0xFFF #define LAST_CLUSTER 0xFFFF @@ -64,7 +63,6 @@ typedef int BOOL; #define TRUE 1 #define FALSE 0 -#define NIL_PTR ((char *) 0) #define DOS_TIME 315532800L /* 1970 - 1980 */ @@ -75,9 +73,9 @@ typedef int BOOL; #define LABEL 4 #define ENTRY 5 #define find_entry(d, e, p) directory(d, e, FIND, p) -#define list_dir(d, e, f) (void) directory(d, e, f, NIL_PTR) -#define label() directory(root, root_entries, LABEL, NIL_PTR) -#define new_entry(d, e) directory(d, e, ENTRY, NIL_PTR) +#define list_dir(d, e, f) (void) directory(d, e, f, NULL) +#define label() directory(root, root_entries, LABEL, NULL) +#define new_entry(d, e) directory(d, e, ENTRY, NULL) #define is_dir(d) ((d)->d_attribute & SUB_DIR) @@ -362,12 +360,12 @@ register char *argv[]; if (dos_dir && Lflag) { entry = label(); printf ("Volume in drive %c ", dev_nr); - if (entry == NIL_DIR) + if (entry == NULL) printf("has no label.\n\n"); else printf ("is %.11s\n\n", entry->d_name); } - if (argv[idx] == NIL_PTR) { + if (argv[idx] == NULL) { if (!dos_dir) usage(argv[0]); if (Lflag) printf ("Root directory:\n"); list_dir(root, root_entries, FALSE); @@ -393,7 +391,7 @@ register char *argv[]; } else if (dos_read) extract(entry); else { - if (entry != NIL_DIR) { + if (entry != NULL) { fflush (stdout); if (is_dir(entry)) fprintf (stderr, "%s: %s is a directory.\n", cmnd, path); @@ -401,7 +399,7 @@ register char *argv[]; fprintf (stderr, "%s: %s already exists.\n", cmnd, argv[idx]); exit(1); } - add_path(NIL_PTR, TRUE); + add_path(NULL, TRUE); if (*path) make_file(find_entry(root, root_entries, path), sub_entries, slash(argv[idx])); @@ -445,7 +443,7 @@ int function; register char *pathname; { register DIRECTORY *dir_ptr = dir; - DIRECTORY *mem = NIL_DIR; + DIRECTORY *mem = NULL; unsigned short cl_no = dir->d_cluster; unsigned short type, last = 0; char file_name[14]; @@ -528,7 +526,7 @@ register char *pathname; printf ( "Directory %s%s:\n", path, name); add_path(name, FALSE); list_dir(dir_ptr, sub_entries, FALSE); - add_path(NIL_PTR, FALSE); + add_path(NULL, FALSE); } } } @@ -537,12 +535,12 @@ register char *pathname; switch (function) { case FIND: - if (dos_write && *pathname == '\0') return NIL_DIR; + if (dos_write && *pathname == '\0') return NULL; fflush (stdout); fprintf (stderr, "%s: Cannot find `%s'.\n", cmnd, file_name); exit(1); case LABEL: - return NIL_DIR; + return NULL; case ENTRY: if (!mem) { fflush (stdout); @@ -1079,7 +1077,7 @@ BOOL slash_fl; while (*ptr) ptr++; - if (file == NIL_PTR) { + if (file == NULL) { if (ptr != path) ptr--; if (ptr != path) do { ptr--; diff --git a/commands/mined/mined.h b/commands/mined/mined.h index 48c20c630..5d076fe8f 100644 --- a/commands/mined/mined.h +++ b/commands/mined/mined.h @@ -128,10 +128,6 @@ struct regex { typedef struct regex REGEX; /* NULL definitions */ -#define NIL_PTR ((char *) 0) -#define NIL_LINE ((LINE *) 0) -#define NIL_REG ((REGEX *) 0) -#define NIL_INT ((int *) 0) /* * Forward declarations @@ -210,7 +206,7 @@ extern long chars_saved; /* Nr of chars saved in buffer */ /* * Move to coordinates and set textp. (Don't use address) */ -#define move_to(nx, ny) move((nx), NIL_PTR, (ny)) +#define move_to(nx, ny) move((nx), NULL, (ny)) /* * Move to coordinates on screen as indicated by textp. @@ -221,12 +217,12 @@ extern long chars_saved; /* Nr of chars saved in buffer */ * Functions handling status_line. ON means in reverse video. */ #define status_line(str1, str2) (void) bottom_line(ON, (str1), \ - (str2), NIL_PTR, FALSE) + (str2), NULL, FALSE) #define error(str1, str2) (void) bottom_line(ON, (str1), \ - (str2), NIL_PTR, FALSE) -#define get_string(str1,str2, fl) bottom_line(ON, (str1), NIL_PTR, (str2), fl) -#define clear_status() (void) bottom_line(OFF, NIL_PTR, NIL_PTR, \ - NIL_PTR, FALSE) + (str2), NULL, FALSE) +#define get_string(str1,str2, fl) bottom_line(ON, (str1), NULL, (str2), fl) +#define clear_status() (void) bottom_line(OFF, NULL, NULL, \ + NULL, FALSE) /* * Print info about current file and buffer. diff --git a/commands/mined/mined1.c b/commands/mined/mined1.c index 7c1f88fb7..b72e70e37 100644 --- a/commands/mined/mined1.c +++ b/commands/mined/mined1.c @@ -111,7 +111,7 @@ * * A special structure is allocated and its address is assigned to the * variable header as well as the variable tail. The text field of this - * structure is set to NIL_PTR. The tail->prev of this structure points + * structure is set to NULL. The tail->prev of this structure points * to the last LINE of the file and the header->next to the first LINE. * Other LINE *variables are top_line and bot_line which point to the * first line resp. the last line on the screen. @@ -238,7 +238,7 @@ * startposition on the current line, and a flag indicating FORWARD or * REVERSE search. Match () checks out the whole file until a match is * found. If match is found it returns a pointer to the line in which the - * match was found else it returns a NIL_LINE. Line_check () takes the + * match was found else it returns a NULL. Line_check () takes the * same arguments, but return either MATCH or NO_MATCH. * During checking, the start_ptr and end_ptr fields of the REGEX * structure are assigned to the start and end of the match. @@ -259,7 +259,7 @@ * backwards search (SR)) call search () with an apropiate message and a * flag indicating FORWARD or REVERSE search. Search () will get an * expression from the user by calling get_expression(). Get_expression() - * returns a pointer to a REGEX structure or NIL_REG upon errors and + * returns a pointer to a REGEX structure or NULL upon errors and * prompts for the expression. If no expression if given, the previous is * used instead. After that search will call match (), and if a match is * found, we can move to that place in the file by the functions find_x() @@ -452,7 +452,7 @@ void VI() #else string_print (enter_string); #endif /* UNIX */ - load_file(new_file[0] == '\0' ? NIL_PTR : new_file); + load_file(new_file[0] == '\0' ? NULL : new_file); } /* @@ -466,7 +466,7 @@ int WT() int fd; /* Filedescriptor of file */ if (modified == FALSE) { - error ("Write not necessary.", NIL_PTR); + error ("Write not necessary.", NULL); return FINE; } @@ -532,11 +532,11 @@ void SH() int pid, status; char *shell; - if ((shell = getenv("SHELL")) == NIL_PTR) shell = "/bin/sh"; + if ((shell = getenv("SHELL")) == NULL) shell = "/bin/sh"; switch (pid = fork()) { case -1: /* Error */ - error("Cannot fork.", NIL_PTR); + error("Cannot fork.", NULL); return; case 0: /* This is the child */ set_cursor(0, ymax); @@ -564,7 +564,7 @@ void SH() if ((status >> 8) == 127) /* Child died with 127 */ error("Cannot exec ", shell); else if ((status >> 8) == 126) - error("Cannot open /dev/tty as fd #0", NIL_PTR); + error("Cannot open /dev/tty as fd #0", NULL); } /* @@ -601,10 +601,10 @@ FLAG statfl; register char *p = buf; *p++ = ' '; - if (s1 != NIL_PTR) + if (s1 != NULL) while (*p = *s1++) p++; - if (s2 != NIL_PTR) + if (s2 != NULL) while (*p = *s2++) p++; *p++ = ' '; @@ -626,7 +626,7 @@ FLAG statfl; string_print(buf); - if (inbuf != NIL_PTR) + if (inbuf != NULL) ret = input(inbuf, statfl); /* Print normal video */ @@ -637,7 +637,7 @@ FLAG statfl; string_print(normal_video); string_print(blank_line); /* Clear the rest of the line */ #endif /* UNIX */ - if (inbuf != NIL_PTR) + if (inbuf != NULL) set_cursor(0, ymax); else set_cursor(x, y); /* Set cursor back to old position */ @@ -713,7 +713,7 @@ char *new_address; } /* Set or unset relative x-coordinate */ - if (new_address == NIL_PTR) { + if (new_address == NULL) { new_address = find_address(line, (new_x == x) ? rel_x : new_x , &tx); if (new_x != x) rel_x = tx; @@ -805,7 +805,7 @@ register char *string; { register int count = 0; - if (string != NIL_PTR) { + if (string != NULL) { while (*string++ != '\0') count++; } @@ -1061,7 +1061,7 @@ int fd; build_string(text_buffer, "Command aborted: %s (File incomplete)", (errno == ENOSPC || errno == -ENOSPC) ? "No space on device" : "Write error"); - error(text_buffer, NIL_PTR); + error(text_buffer, NULL); } /* @@ -1083,7 +1083,7 @@ void abort_mined() quit = FALSE; /* Ask for confirmation */ - status_line("Really abort? ", NIL_PTR); + status_line("Really abort? ", NULL); if (getchar() != 'y') { clear_status(); return; @@ -1172,7 +1172,7 @@ int bytes; char *p; p = malloc((unsigned) bytes); - if (p == NIL_PTR) { + if (p == NULL) { if (loading == TRUE) panic("File too big."); panic("Out of memory."); @@ -1281,14 +1281,14 @@ char *basename(path) char *path; { register char *ptr = path; - register char *last = NIL_PTR; + register char *last = NULL; while (*ptr != '\0') { if (*ptr == '/') last = ptr; ptr++; } - if (last == NIL_PTR) + if (last == NULL) return path; if (*(last + 1) == '\0') { /* E.g. /usr/tmp/pipo/ */ *last = '\0'; @@ -1298,7 +1298,7 @@ char *path; } /* - * Load_file loads the file `file' into core. If file is a NIL_PTR or the file + * Load_file loads the file `file' into core. If file is a NULL or the file * couldn't be opened, just some initializations are done, and a line consisting * of a `\n' is installed. */ @@ -1314,9 +1314,9 @@ char *file; /* Open file */ writable = TRUE; /* Benefit of the doubt */ - if (file == NIL_PTR) { + if (file == NULL) { if (rpipe == FALSE) - status_line("No file.", NIL_PTR); + status_line("No file.", NULL); else { fd = 0; file = "standard input"; @@ -1370,8 +1370,8 @@ int get_line(fd, buffer) int fd; register char *buffer; { - static char *last = NIL_PTR; - static char *current = NIL_PTR; + static char *last = NULL; + static char *current = NULL; static int read_chars; register char *cur_pos = current; char *begin = buffer; @@ -1455,14 +1455,14 @@ char *argv[]; raw_mode(ON); /* Set tty to appropriate mode */ header = tail = (LINE *) alloc(sizeof(LINE)); /* Make header of list*/ - header->text = NIL_PTR; + header->text = NULL; header->next = tail->prev = header; /* Load the file (if any) */ if (argc < 2) - load_file(NIL_PTR); + load_file(NULL); else { - (void) get_file(NIL_PTR, argv[1]); /* Truncate filename */ + (void) get_file(NULL, argv[1]); /* Truncate filename */ load_file(argv[1]); } @@ -1652,7 +1652,7 @@ void ESC() } if (quit == TRUE) /* Abort has been given */ - error("Aborted", NIL_PTR); + error("Aborted", NULL); } /* @@ -1735,7 +1735,7 @@ FLAG writefl, changed; msg[LINE_LEN - 4] = SHIFT_MARK; /* Overflow on status line */ msg[LINE_LEN - 3] = '\0'; } - status_line(msg, NIL_PTR); /* Print the information */ + status_line(msg, NULL); /* Print the information */ } /* @@ -1828,11 +1828,11 @@ int *result; register int index; register int count = 0; - status_line(message, NIL_PTR); + status_line(message, NULL); index = getchar(); if (quit == FALSE && (index < '0' || index > '9')) { - error("Bad count", NIL_PTR); + error("Bad count", NULL); return ERRORS; } @@ -1923,7 +1923,7 @@ char *message, *file; char *ptr; int ret; - if (message == NIL_PTR || (ret = get_string(message, file, TRUE)) == FINE) { + if (message == NULL || (ret = get_string(message, file, TRUE)) == FINE) { if (length_of((ptr = basename(file))) > NAME_MAX) ptr[NAME_MAX] = '\0'; } diff --git a/commands/mined/mined2.c b/commands/mined/mined2.c index 1b16d8797..cea47d893 100644 --- a/commands/mined/mined2.c +++ b/commands/mined/mined2.c @@ -471,13 +471,13 @@ void CTL() { register char ctrl; - status_line("Enter control character.", NIL_PTR); + status_line("Enter control character.", NULL); if ((ctrl = getchar()) >= '\01' && ctrl <= '\037') { S(ctrl); /* Insert the char */ clear_status(); } else - error ("Unknown control character", NIL_PTR); + error ("Unknown control character", NULL); } /* @@ -528,7 +528,7 @@ char *location, *string; register char *textp = line->text; if (length_of(textp) + length_of(string) >= MAX_CHARS) { - error("Line too long", NIL_PTR); + error("Line too long", NULL); return ERRORS; } @@ -607,12 +607,12 @@ char *start_textp, *end_textp; /* Check if line doesn't exceed MAX_CHARS */ if (count + length_of(end_textp) >= MAX_CHARS) { - error("Line too long", NIL_PTR); + error("Line too long", NULL); return; } /* Copy last part of end_line if end_line is not tail */ - copy_string(bufp, (end_textp != NIL_PTR) ? end_textp : "\n"); + copy_string(bufp, (end_textp != NULL) ? end_textp : "\n"); /* Delete all lines between start and end_position (including end_line) */ line = start_line->next; @@ -623,7 +623,7 @@ char *start_textp, *end_textp; } /* Check if last line of file should be deleted */ - if (end_textp == NIL_PTR && length_of(start_line->text) == 1 && nlines > 1) { + if (end_textp == NULL && length_of(start_line->text) == 1 && nlines > 1) { start_line = start_line->prev; (void) line_delete(start_line->next); line_cnt++; @@ -681,7 +681,7 @@ void PT() register int fd; /* File descriptor for buffer */ if ((fd = scratch_file(READ)) == ERRORS) - error("Buffer is empty.", NIL_PTR); + error("Buffer is empty.", NULL); else { file_insert(fd, FALSE);/* Insert the buffer */ (void) close(fd); @@ -782,7 +782,7 @@ void WB() /* Checkout the buffer */ if ((yank_fd = scratch_file(READ)) == ERRORS) { - error("Buffer is empty.", NIL_PTR); + error("Buffer is empty.", NULL); return; } @@ -821,7 +821,7 @@ void MA() { mark_line = cur_line; mark_text = cur_text; - status_line("Mark set", NIL_PTR); + status_line("Mark set", NULL); } /* @@ -851,7 +851,7 @@ FLAG remove; /* DELETE if text should be deleted */ { switch (checkmark()) { case NOT_VALID : - error("Mark not set.", NIL_PTR); + error("Mark not set.", NULL); return; case SMALLER : yank(mark_line, mark_text, cur_line, cur_text, remove); @@ -862,7 +862,7 @@ FLAG remove; /* DELETE if text should be deleted */ case SAME : /* Ignore stupid behaviour */ yank_status = EMPTY; chars_saved = 0L; - status_line("0 characters saved in buffer.", NIL_PTR); + status_line("0 characters saved in buffer.", NULL); break; } } @@ -938,7 +938,7 @@ FLAG remove; /* DELETE if text should be deleted */ chars_saved = 0L; lines_saved = 0; - status_line("Saving text.", NIL_PTR); + status_line("Saving text.", NULL); /* Keep writing chars until the end_location is reached. */ while (textp != end_textp) { @@ -1005,7 +1005,7 @@ FLAG mode; /* Can be READ or WRITE permission */ /* Check file existence */ if (access(yank_file, 0) == 0 || (fd = creat(yank_file, 0644)) < 0) { if (trials++ >= MAXTRAILS) { - error("Unable to creat scratchfile.", NIL_PTR); + error("Unable to creat scratchfile.", NULL); return ERRORS; } else @@ -1065,7 +1065,7 @@ void SR() /* * Get_expression() prompts for an expression. If just a return is typed, the * old expression is used. If the expression changed, compile() is called and - * the returning REGEX structure is returned. It returns NIL_REG upon error. + * the returning REGEX structure is returned. It returns NULL upon error. * The save flag indicates whether the expression should be appended at the * message pointer. */ @@ -1076,11 +1076,11 @@ char *message; char exp_buf[LINE_LEN]; /* Buffer for new expr. */ if (get_string(message, exp_buf, FALSE) == ERRORS) - return NIL_REG; + return NULL; if (exp_buf[0] == '\0' && typed_expression[0] == '\0') { - error("No previous expression.", NIL_PTR); - return NIL_REG; + error("No previous expression.", NULL); + return NULL; } if (exp_buf[0] != '\0') { /* A new expr. is typed */ @@ -1089,8 +1089,8 @@ char *message; } if (program.status == REG_ERROR) { /* Error during compiling */ - error(program.result.err_mess, NIL_PTR); - return NIL_REG; + error(program.result.err_mess, NULL); + return NULL; } return &program; } @@ -1133,7 +1133,7 @@ FLAG file; /* Save message and get expression */ copy_string(mess_buf, message); - if ((program = get_expression(mess_buf)) == NIL_REG) + if ((program = get_expression(mess_buf)) == NULL) return; /* Get substitution pattern */ @@ -1151,7 +1151,7 @@ FLAG file; do { subs++; /* Increment subs */ if ((textp = substitute(line, program,replacement)) - == NIL_PTR) + == NULL) return; /* Line too long */ } while ((program->status & BEGIN_LINE) != BEGIN_LINE && (program->status & END_LINE) != END_LINE && @@ -1170,11 +1170,11 @@ FLAG file; copy_string(mess_buf, (quit == TRUE) ? "(Aborted) " : ""); /* Fix the status line */ if (subs == 0L && quit == FALSE) - error("Pattern not found.", NIL_PTR); + error("Pattern not found.", NULL); else if (lines >= REPORT || quit == TRUE) { build_string(mess_buf, "%s %D substitutions on %D lines.", mess_buf, subs, lines); - status_line(mess_buf, NIL_PTR); + status_line(mess_buf, NULL); } else if (file == NOT_VALID && subs >= REPORT) status_line(num_out(subs), " substitutions."); @@ -1224,8 +1224,8 @@ char *replacement; /* Contains replacement pattern */ /* Check for line length not exceeding MAX_CHARS */ if (length_of(text_buffer) + length_of(program->end_ptr) >= MAX_CHARS) { - error("Substitution result: line too big", NIL_PTR); - return NIL_PTR; + error("Substitution result: line too big", NULL); + return NULL; } /* Append last part of line to the new build line */ @@ -1242,7 +1242,7 @@ char *replacement; /* Contains replacement pattern */ /* * Search() calls get_expression to fetch the expression. If this went well, * the function match() is called which returns the line with the next match. - * If this line is the NIL_LINE, it means that a match could not be found. + * If this line is the NULL, it means that a match could not be found. * Find_x() and find_y() display the right page on the screen, and return * the right coordinates for x and y. These coordinates are passed to move_to() */ @@ -1254,17 +1254,17 @@ FLAG method; register LINE *match_line; /* Get the expression */ - if ((program = get_expression(message)) == NIL_REG) + if ((program = get_expression(message)) == NULL) return; set_cursor(0, ymax); flush(); /* Find the match */ - if ((match_line = match(program, cur_text, method)) == NIL_LINE) { + if ((match_line = match(program, cur_text, method)) == NULL) { if (quit == TRUE) - status_line("Aborted", NIL_PTR); + status_line("Aborted", NULL); else - status_line("Pattern not found.", NIL_PTR); + status_line("Pattern not found.", NULL); return; } @@ -1499,7 +1499,7 @@ REGEX *program; * Match gets as argument the program, pointer to place in current line to * start from and the method to search for (either FORWARD or REVERSE). * Match() will look through the whole file until a match is found. - * NIL_LINE is returned if no match could be found. + * NULL is returned if no match could be found. */ LINE *match(program, string, method) REGEX *program; @@ -1511,7 +1511,7 @@ register FLAG method; /* Corrupted program */ if (program->status == REG_ERROR) - return NIL_LINE; + return NULL; /* Check part of text first */ if (!(program->status & BEGIN_LINE)) { @@ -1533,14 +1533,14 @@ register FLAG method; /* No match in last (or first) part of line. Check out rest of file */ do { line = (method == FORWARD) ? line->next : line->prev; - if (line->text == NIL_PTR) /* Header/tail */ + if (line->text == NULL) /* Header/tail */ continue; if (line_check(program, line->text, method) == MATCH) return line; } while (line != cur_line && quit == FALSE); /* No match found. */ - return NIL_LINE; + return NULL; } /* @@ -1560,7 +1560,7 @@ FLAG method; /* If the match must be anchored, just check the string. */ if (program->status & BEGIN_LINE) - return check_string(program, string, NIL_INT); + return check_string(program, string, NULL); if (method == REVERSE) { /* First move to the end of the string */ @@ -1569,7 +1569,7 @@ FLAG method; /* Start checking string until the begin of the string is met */ while (textp >= string) { program->start_ptr = textp; - if (check_string(program, textp--, NIL_INT)) + if (check_string(program, textp--, NULL)) return MATCH; } } @@ -1577,7 +1577,7 @@ FLAG method; /* Move through the string until the end of is found */ while (quit == FALSE && *textp != '\0') { program->start_ptr = textp; - if (check_string(program, textp, NIL_INT)) + if (check_string(program, textp, NULL)) return MATCH; if (*textp == '\n') break; @@ -1606,7 +1606,7 @@ int *expression; char *mark; /* For marking position */ int star_fl; /* A star has been born */ - if (expression == NIL_INT) + if (expression == NULL) expression = program->result.expression; /* Loop until end of string or end of expression */ diff --git a/commands/simple/sort.c b/commands/simple/sort.c index 09a7d348c..4725ea45d 100644 --- a/commands/simple/sort.c +++ b/commands/simple/sort.c @@ -55,7 +55,6 @@ /* Return status of functions */ #define OK 0 #define ERROR -1 -#define NIL_PTR ((char *) 0) /* Compare return values */ #define LOWER -1 @@ -82,7 +81,6 @@ typedef struct { char *line; /* Contains line currently used */ } MERGE; -#define NIL_MERGE ((MERGE *) 0) MERGE merge_f[OPEN_FILES]; /* Merge structs */ int buf_size; /* Size of core available for each struct */ @@ -256,7 +254,7 @@ register FIELD *field; field->reverse = TRUE; break; default: /* Illegal options */ - error(TRUE, USAGE, NIL_PTR); + error(TRUE, USAGE, NULL); } } @@ -302,7 +300,7 @@ BOOL beg_fl; /* Assign beg or end of field */ if (ptr && *ptr == '-' && ((table[*(ptr + 1)] & DIGIT) || *(ptr + 1) == '.')) { new_field(field, offset, FALSE); if (field->beg_field > field->end_field) - error(TRUE, "End field is before start field!", NIL_PTR); + error(TRUE, "End field is before start field!", NULL); } else /* No end pos. */ field->end_field = ERROR; } @@ -326,7 +324,7 @@ char *argv[]; break; if (*ptr == '+') { /* Assign field. */ if (++field_cnt == FIELDS_LIMIT) - error(TRUE, "Too many fields", NIL_PTR); + error(TRUE, "Too many fields", NULL); new_field(&fields[field_cnt], &arg_count, TRUE); } else { /* Get output options */ while (*++ptr) { @@ -372,14 +370,14 @@ char *argv[]; /* Only merge files. Set up */ if (only_merge) { args_limit = args_offset = arg_count; - while (argv[args_limit] != NIL_PTR) + while (argv[args_limit] != NULL) args_limit++; /* Find nr of args */ files_merge(args_limit - arg_count); exit(0); } if (arg_count == argc) { /* No args left. Use stdin */ if (check) - check_file(0, NIL_PTR); + check_file(0, NULL); else get_file(0, (off_t) 0); } else @@ -436,7 +434,7 @@ register BOOL quit; register char *message, *arg; { write(2, message, strlen(message)); - if (arg != NIL_PTR) write(2, arg, strlen(arg)); + if (arg != NULL) write(2, arg, strlen(arg)); perror(" "); if (quit) exit(1); } @@ -446,7 +444,7 @@ register char *message, *arg; */ void open_outfile() { - if (output_file == NIL_PTR) + if (output_file == NULL) out_fd = STD_OUT; else if ((out_fd = creat(output_file, 0644)) < 0) error(TRUE, "Cannot creat ", output_file); @@ -534,10 +532,10 @@ int fd; if ((fd = creat(file_name(nr_of_files), 0644)) < 0) error(TRUE, "Cannot creat ", file_name(nr_of_files)); } - for (line_ptr = line_table; *line_ptr != NIL_PTR; line_ptr++) { + for (line_ptr = line_table; *line_ptr != NULL; line_ptr++) { ptr = *line_ptr; /* Skip all same lines if uniq is set */ - if (uniq && *(line_ptr + 1) != NIL_PTR) { + if (uniq && *(line_ptr + 1) != NULL) { if (compare(ptr, *(line_ptr + 1)) == SAME) continue; } do { /* Print line in a buffered way */ @@ -575,7 +573,7 @@ char *address; register int bytes; { if (read(fd, address, bytes) < 0 && bytes != 0) - error(TRUE, "Read error", NIL_PTR); + error(TRUE, "Read error", NULL); } /* Mwrite () performs a normal write (), but checks the return value. */ @@ -585,7 +583,7 @@ char *address; register int bytes; { if (write(fd, address, bytes) != bytes && bytes != 0) - error(TRUE, "Write error", NIL_PTR); + error(TRUE, "Write error", NULL); } /* Sort () sorts the input in memory starting at mem_top. */ @@ -608,7 +606,7 @@ void sort() if (*ptr++ == '\n') line_table[count++] = ptr; } - line_table[count - 1] = NIL_PTR; + line_table[count - 1] = NULL; /* Sort the line table */ sort_table(count - 1); @@ -972,20 +970,20 @@ int start_file, limit_file; if (only_merge && uniq) uniq_lines(smallest); /* Print only uniq lines */ else /* Print rest of file */ - while (print(smallest, file_cnt) != NIL_MERGE); + while (print(smallest, file_cnt) != NULL); - put_line(NIL_PTR); /* Flush output buffer */ + put_line(NULL); /* Flush output buffer */ } /* Put_line () prints the line into the out_fd filedescriptor. If line equals - * NIL_PTR, the out_fd is flushed and closed. + * NULL, the out_fd is flushed and closed. */ void put_line(line) register char *line; { static int index = 0; /* Index in out_buffer */ - if (line == NIL_PTR) { /* Flush and close */ + if (line == NULL) { /* Flush and close */ mwrite(out_fd, out_buffer, index); index = 0; (void) close(out_fd); @@ -1021,7 +1019,7 @@ int file_cnt; /* Nr of files that are being merged */ } } if (i == file_cnt) /* No more files left */ - return NIL_MERGE; + return NULL; } return merg; } @@ -1170,7 +1168,7 @@ register int size; register char *address; if ((address = sbrk(size)) == (char *) -1) - error(TRUE, "Not enough memory. Use chmem to allocate more", NIL_PTR); + error(TRUE, "Not enough memory. Use chmem to allocate more", NULL); return address; } @@ -1178,7 +1176,7 @@ register int size; void mbrk(address) char *address; { - if (brk(address) == -1) error(TRUE, "Cannot reset memory", NIL_PTR); + if (brk(address) == -1) error(TRUE, "Cannot reset memory", NULL); } void catch(dummy) diff --git a/drivers/at_wini/at_wini.c b/drivers/at_wini/at_wini.c index 13b53b01a..c73183be7 100644 --- a/drivers/at_wini/at_wini.c +++ b/drivers/at_wini/at_wini.c @@ -579,7 +579,7 @@ PRIVATE int w_do_open(struct driver *dp, message *m_ptr) struct wini *wn; - if (w_prepare(m_ptr->DEVICE) == NIL_DEV) return(ENXIO); + if (w_prepare(m_ptr->DEVICE) == NULL) return(ENXIO); wn = w_wn; @@ -657,7 +657,7 @@ PRIVATE struct device *w_prepare(int device) w_dv = &w_wn->subpart[device % SUB_PER_DRIVE]; } else { w_device = -1; - return(NIL_DEV); + return(NULL); } return(w_dv); } @@ -954,13 +954,13 @@ PRIVATE int w_io_test(void) w_testing = 1; /* Try I/O on the actual drive (not any (sub)partition). */ - if (w_prepare(w_drive * DEV_PER_DRIVE) == NIL_DEV) + if (w_prepare(w_drive * DEV_PER_DRIVE) == NULL) panic("Couldn't switch devices"); r = w_transfer(SELF, DEV_GATHER_S, cvu64(0), &iov, 1); /* Switch back. */ - if (w_prepare(save_dev) == NIL_DEV) + if (w_prepare(save_dev) == NULL) panic("Couldn't switch back devices"); /* Restore parameters. */ @@ -1726,7 +1726,7 @@ PRIVATE void w_need_reset() PRIVATE int w_do_close(struct driver *dp, message *m_ptr) { /* Device close: Release a device. */ - if (w_prepare(m_ptr->DEVICE) == NIL_DEV) + if (w_prepare(m_ptr->DEVICE) == NULL) return(ENXIO); w_wn->open_ct--; #if ENABLE_ATAPI @@ -2352,7 +2352,7 @@ message *m; return OK; } else if (m->REQUEST == DIOCOPENCT) { int count; - if (w_prepare(m->DEVICE) == NIL_DEV) return ENXIO; + if (w_prepare(m->DEVICE) == NULL) return ENXIO; count = w_wn->open_ct; r= sys_safecopyto(m->IO_ENDPT, (cp_grant_id_t) m->IO_GRANT, 0, (vir_bytes)&count, sizeof(count), D); diff --git a/drivers/bios_wini/bios_wini.c b/drivers/bios_wini/bios_wini.c index bd44a5313..96a9f4093 100644 --- a/drivers/bios_wini/bios_wini.c +++ b/drivers/bios_wini/bios_wini.c @@ -159,10 +159,10 @@ int device; w_wn = &wini[w_drive]; w_dv = &w_wn->subpart[device % SUB_PER_DRIVE]; } else { - return(NIL_DEV); + return(NULL); } if (w_drive >= MAX_DRIVES || !w_wn->present) - return NIL_DEV; + return NULL; return(w_dv); } @@ -369,7 +369,7 @@ message *m_ptr; if (!init_done) { w_init(); init_done = TRUE; } - if (w_prepare(m_ptr->DEVICE) == NIL_DEV) return(ENXIO); + if (w_prepare(m_ptr->DEVICE) == NULL) return(ENXIO); if (w_wn->open_ct++ == 0) { /* Partition the disk. */ @@ -387,7 +387,7 @@ message *m_ptr; { /* Device close: Release a device. */ - if (w_prepare(m_ptr->DEVICE) == NIL_DEV) return(ENXIO); + if (w_prepare(m_ptr->DEVICE) == NULL) return(ENXIO); w_wn->open_ct--; return(OK); } @@ -526,7 +526,7 @@ PRIVATE int w_other(struct driver *UNUSED(dr), message *m) if (m->REQUEST == DIOCOPENCT) { int count; - if (w_prepare(m->DEVICE) == NIL_DEV) return ENXIO; + if (w_prepare(m->DEVICE) == NULL) return ENXIO; count = w_wn->open_ct; r=sys_safecopyto(m->IO_ENDPT, (cp_grant_id_t)m->IO_GRANT, 0, (vir_bytes)&count, sizeof(count), D); diff --git a/drivers/floppy/floppy.c b/drivers/floppy/floppy.c index cf8cd9080..d8384d8e7 100644 --- a/drivers/floppy/floppy.c +++ b/drivers/floppy/floppy.c @@ -456,7 +456,7 @@ PRIVATE struct device *f_prepare(int device) f_device = device; f_drive = device & ~(DEV_TYPE_BITS | FORMAT_DEV_BIT); - if (f_drive < 0 || f_drive >= NR_DRIVES) return(NIL_DEV); + if (f_drive < 0 || f_drive >= NR_DRIVES) return(NULL); f_fp = &floppy[f_drive]; f_dv = &f_fp->fl_geom; @@ -1316,7 +1316,7 @@ message *m_ptr; /* pointer to open message */ struct test_order *top; /* Decode the message parameters. */ - if (f_prepare(m_ptr->DEVICE) == NIL_DEV) return(ENXIO); + if (f_prepare(m_ptr->DEVICE) == NULL) return(ENXIO); dtype = f_device & DEV_TYPE_BITS; /* get density from minor dev */ if (dtype >= MINOR_fd0p0) dtype = 0; diff --git a/drivers/log/log.c b/drivers/log/log.c index a2e72ec42..84e3e5257 100644 --- a/drivers/log/log.c +++ b/drivers/log/log.c @@ -149,7 +149,7 @@ int device; { /* Prepare for I/O on a device: check if the minor device number is ok. */ - if (device < 0 || device >= NR_DEVS) return(NIL_DEV); + if (device < 0 || device >= NR_DEVS) return(NULL); log_device = device; return(&log_geom[device]); @@ -373,7 +373,7 @@ PRIVATE int log_do_open(dp, m_ptr) struct driver *dp; message *m_ptr; { - if (log_prepare(m_ptr->DEVICE) == NIL_DEV) return(ENXIO); + if (log_prepare(m_ptr->DEVICE) == NULL) return(ENXIO); return(OK); } diff --git a/drivers/memory/memory_driver/memory.c b/drivers/memory/memory_driver/memory.c index 513af8cc1..3e7a9469c 100644 --- a/drivers/memory/memory_driver/memory.c +++ b/drivers/memory/memory_driver/memory.c @@ -177,7 +177,7 @@ PRIVATE struct device *m_prepare(device) int device; { /* Prepare for I/O on a device: check if the minor device number is ok. */ - if (device < 0 || device >= NR_DEVS) return(NIL_DEV); + if (device < 0 || device >= NR_DEVS) return(NULL); m_device = device; return(&m_geom[device]); @@ -352,7 +352,7 @@ message *m_ptr; int r; /* Check device number on open. */ - if (m_prepare(m_ptr->DEVICE) == NIL_DEV) return(ENXIO); + if (m_prepare(m_ptr->DEVICE) == NULL) return(ENXIO); if (m_device == MEM_DEV) { r = sys_enable_iop(m_ptr->IO_ENDPT); @@ -382,7 +382,7 @@ message *m_ptr; { int r; - if (m_prepare(m_ptr->DEVICE) == NIL_DEV) return(ENXIO); + if (m_prepare(m_ptr->DEVICE) == NULL) return(ENXIO); if(m_device < 0 || m_device >= NR_DEVS) { panic("wrong m_device: %d", m_device); @@ -423,7 +423,7 @@ message *m_ptr; /* pointer to control message */ if((dev < RAM_DEV_FIRST || dev > RAM_DEV_LAST) && dev != RAM_DEV_OLD) { printf("MEM: MIOCRAMSIZE: %d not a ramdisk\n", dev); } - if ((dv = m_prepare(dev)) == NIL_DEV) return(ENXIO); + if ((dv = m_prepare(dev)) == NULL) return(ENXIO); /* Get request structure */ s= sys_safecopyfrom(m_ptr->IO_ENDPT, (vir_bytes)m_ptr->IO_GRANT, diff --git a/drivers/random/main.c b/drivers/random/main.c index 28cc902df..f6c59a026 100644 --- a/drivers/random/main.c +++ b/drivers/random/main.c @@ -142,7 +142,7 @@ int device; { /* Prepare for I/O on a device: check if the minor device number is ok. */ - if (device < 0 || device >= NR_DEVS) return(NIL_DEV); + if (device < 0 || device >= NR_DEVS) return(NULL); m_device = device; return(&m_geom[device]); @@ -233,7 +233,7 @@ message *m_ptr; { /* Check device number on open. */ - if (r_prepare(m_ptr->DEVICE) == NIL_DEV) return(ENXIO); + if (r_prepare(m_ptr->DEVICE) == NULL) return(ENXIO); return(OK); } @@ -245,7 +245,7 @@ PRIVATE int r_ioctl(dp, m_ptr) struct driver *dp; /* pointer to driver structure */ message *m_ptr; /* pointer to control message */ { - if (r_prepare(m_ptr->DEVICE) == NIL_DEV) return(ENXIO); + if (r_prepare(m_ptr->DEVICE) == NULL) return(ENXIO); switch (m_ptr->REQUEST) { diff --git a/include/minix/const.h b/include/minix/const.h index 736980c9d..14bd7ce9c 100644 --- a/include/minix/const.h +++ b/include/minix/const.h @@ -51,7 +51,6 @@ /* Message passing constants. */ #define MESS_SIZE (sizeof(message)) /* might need usizeof from FS here */ -#define NIL_MESS ((message *) 0) /* null pointer */ /* Memory related constants. */ #define SEGMENT_TYPE 0xFF00 /* bit mask to get segment type */ @@ -89,7 +88,6 @@ #define BYTE 0377 /* mask for 8 bits */ #define READING 0 /* copy data to user */ #define WRITING 1 /* copy data from user */ -#define NIL_PTR (char *) 0 /* generally useful expression */ #define HAVE_SCATTERED_IO 1 /* scattered I/O is now standard */ /* Macros. */ diff --git a/include/minix/driver.h b/include/minix/driver.h index 0aeee34f1..0ee53af52 100644 --- a/include/minix/driver.h +++ b/include/minix/driver.h @@ -51,7 +51,6 @@ struct device { u64_t dv_size; }; -#define NIL_DEV ((struct device *) 0) #define DRIVER_STD 0 /* Use the standard reply protocol */ #define DRIVER_ASYN 1 /* Use the new asynchronous protocol */ diff --git a/kernel/arch/i386/exception.c b/kernel/arch/i386/exception.c index 8922307ae..613120eba 100644 --- a/kernel/arch/i386/exception.c +++ b/kernel/arch/i386/exception.c @@ -121,7 +121,7 @@ PUBLIC void exception_handler(int is_nested, struct exception_frame * frame) { "Stack exception", SIGSEGV, 286 }, /* STACK_FAULT already used */ { "General protection", SIGSEGV, 286 }, { "Page fault", SIGSEGV, 386 }, /* not close */ - { NIL_PTR, SIGILL, 0 }, /* probably software trap */ + { NULL, SIGILL, 0 }, /* probably software trap */ { "Coprocessor error", SIGFPE, 386 }, { "Alignment check", SIGBUS, 386 }, { "Machine check", SIGBUS, 386 }, @@ -198,7 +198,7 @@ PUBLIC void exception_handler(int is_nested, struct exception_frame * frame) } /* Exception in system code. This is not supposed to happen. */ - if (ep->msg == NIL_PTR || machine.processor < ep->minprocessor) + if (ep->msg == NULL || machine.processor < ep->minprocessor) printf("\nIntel-reserved exception %d\n", frame->vector); else printf("\n%s\n", ep->msg); diff --git a/kernel/start.c b/kernel/start.c index d70ac8878..ea5bb353f 100644 --- a/kernel/start.c +++ b/kernel/start.c @@ -67,7 +67,7 @@ PUBLIC void cstart( /* XT, AT or MCA bus? */ value = get_value(params_buffer, "bus"); - if (value == NIL_PTR || strcmp(value, "at") == 0) { + if (value == NULL || strcmp(value, "at") == 0) { machine.pc_at = TRUE; /* PC-AT compatible hardware */ } else if (strcmp(value, "mca") == 0) { machine.pc_at = machine.ps_mca = TRUE; /* PS/2 with micro channel */ @@ -132,5 +132,5 @@ PRIVATE char *get_value( while (*envp++ != 0) ; } - return(NIL_PTR); + return(NULL); } diff --git a/lib/libc/posix/_fcntl.c b/lib/libc/posix/_fcntl.c index 5d3ecc94e..92e55d100 100644 --- a/lib/libc/posix/_fcntl.c +++ b/lib/libc/posix/_fcntl.c @@ -20,7 +20,7 @@ int cmd; * covers F_GETFD, F_GETFL and invalid commands. */ m.m1_i3 = 0; - m.m1_p1 = NIL_PTR; + m.m1_p1 = NULL; /* Adjust for the stupid cases. */ switch(cmd) { diff --git a/lib/libdriver/driver.c b/lib/libdriver/driver.c index 295413db6..6d1dd84d8 100644 --- a/lib/libdriver/driver.c +++ b/lib/libdriver/driver.c @@ -455,7 +455,7 @@ message *mp; /* pointer to read or write message */ if (mp->COUNT < 0) return(EINVAL); /* Prepare for I/O. */ - if ((*dp->dr_prepare)(mp->DEVICE) == NIL_DEV) return(ENXIO); + if ((*dp->dr_prepare)(mp->DEVICE) == NULL) return(ENXIO); /* Create a one element scatter/gather vector for the buffer. */ if(mp->m_type == DEV_READ_S) opcode = DEV_GATHER_S; @@ -501,7 +501,7 @@ message *mp; /* pointer to read or write message */ } /* Prepare for I/O. */ - if ((*dp->dr_prepare)(mp->DEVICE) == NIL_DEV) return(ENXIO); + if ((*dp->dr_prepare)(mp->DEVICE) == NULL) return(ENXIO); /* Transfer bytes from/to the device. */ opcode = mp->m_type; @@ -576,7 +576,7 @@ message *mp; PUBLIC struct device *nop_prepare(int device) { /* Nothing to prepare for. */ - return(NIL_DEV); + return(NULL); } /*===========================================================================* @@ -624,7 +624,7 @@ message *mp; /* pointer to ioctl request */ } /* Decode the message parameters. */ - if ((dv = (*dp->dr_prepare)(mp->DEVICE)) == NIL_DEV) return(ENXIO); + if ((dv = (*dp->dr_prepare)(mp->DEVICE)) == NULL) return(ENXIO); if (mp->REQUEST == DIOCSETP) { /* Copy just this one partition table entry. */ diff --git a/lib/libdriver/drvlib.c b/lib/libdriver/drvlib.c index 38f4ce033..fd24a9fe9 100644 --- a/lib/libdriver/drvlib.c +++ b/lib/libdriver/drvlib.c @@ -43,7 +43,7 @@ int atapi; /* atapi device */ unsigned long base, limit, part_limit; /* Get the geometry of the device to partition */ - if ((dv = (*dp->dr_prepare)(device)) == NIL_DEV + if ((dv = (*dp->dr_prepare)(device)) == NULL || cmp64u(dv->dv_size, 0) == 0) return; base = div64u(dv->dv_base, SECTOR_SIZE); limit = base + div64u(dv->dv_size, SECTOR_SIZE); @@ -69,7 +69,7 @@ int atapi; /* atapi device */ } /* Find an array of devices. */ - if ((dv = (*dp->dr_prepare)(device)) == NIL_DEV) return; + if ((dv = (*dp->dr_prepare)(device)) == NULL) return; /* Set the geometry of the partitions from the partition table. */ for (par = 0; par < NR_PARTITIONS; par++, dv++) { @@ -131,7 +131,7 @@ unsigned long extbase; /* sector offset of the base extended partition */ nextoffset = pe->lowsec; } else if (pe->sysind != NO_PART) { - if ((dv = (*dp->dr_prepare)(subdev)) == NIL_DEV) return; + if ((dv = (*dp->dr_prepare)(subdev)) == NULL) return; dv->dv_base = mul64u(extbase + offset + pe->lowsec, SECTOR_SIZE); @@ -163,7 +163,7 @@ struct part_entry *table; /* four entries */ position = mul64u(offset, SECTOR_SIZE); iovec1.iov_addr = (vir_bytes) partbuf; iovec1.iov_size = CD_SECTOR_SIZE; - if ((*dp->dr_prepare)(device) != NIL_DEV) { + if ((*dp->dr_prepare)(device) != NULL) { (void) (*dp->dr_transfer)(SELF, DEV_GATHER_S, position, &iovec1, 1); } if (iovec1.iov_size != 0) { diff --git a/servers/hgfs/hgfs_server/dentry.c b/servers/hgfs/hgfs_server/dentry.c index 6926498e9..07f965154 100644 --- a/servers/hgfs/hgfs_server/dentry.c +++ b/servers/hgfs/hgfs_server/dentry.c @@ -40,7 +40,7 @@ char *name; { /* Given a directory inode and a component name, look up the inode associated * with that directory entry. Return the inode (with increased reference - * count) if found, or NIL_INODE otherwise. + * count) if found, or NULL otherwise. */ struct inode *ino; unsigned int slot; @@ -54,8 +54,8 @@ char *name; break; } - if (ino == NIL_INODE) - return NIL_INODE; + if (ino == NULL) + return NULL; get_inode(ino); @@ -111,7 +111,7 @@ struct inode *ino; * Do not touch open handles. Do not add to the free list. */ - assert(ino->i_parent != NIL_INODE); + assert(ino->i_parent != NULL); /* hash_del(ino); */ LIST_REMOVE(ino, i_hash); diff --git a/servers/hgfs/hgfs_server/inode.c b/servers/hgfs/hgfs_server/inode.c index 0aa688a87..8e0e6336a 100644 --- a/servers/hgfs/hgfs_server/inode.c +++ b/servers/hgfs/hgfs_server/inode.c @@ -40,7 +40,7 @@ PUBLIC struct inode *init_inode() /* Mark all inodes except the root inode as free. */ for (index = 1; index < NUM_INODES; index++) { ino = &inodes[index]; - ino->i_parent = NIL_INODE; + ino->i_parent = NULL; LIST_INIT(&ino->i_child); ino->i_num = index + 1; ino->i_gen = (unsigned short)-1; /* aesthetics */ @@ -78,7 +78,7 @@ ino_t ino_nr; if (index < 0) { printf("HGFS: VFS passed invalid inode number!\n"); - return NIL_INODE; + return NULL; } assert(index < NUM_INODES); @@ -89,7 +89,7 @@ ino_t ino_nr; if (INODE_GEN(ino_nr) != ino->i_gen) { printf("HGFS: VFS passed outdated inode number!\n"); - return NIL_INODE; + return NULL; } /* The VFS/FS protocol only uses referenced inodes. */ @@ -136,7 +136,7 @@ struct inode *ino; dprintf(("HGFS: put_inode(%p) ['%s']\n", ino, ino->i_name)); - assert(ino != NIL_INODE); + assert(ino != NULL); assert(ino->i_ref > 0); ino->i_ref--; @@ -157,7 +157,7 @@ struct inode *ino; /* Add the inode to the head or tail of the free list, depending on whether * it is also deleted (and therefore can never be reused as is). */ - if (ino->i_parent == NIL_INODE) + if (ino->i_parent == NULL) TAILQ_INSERT_HEAD(&free_list, ino, i_free); else TAILQ_INSERT_TAIL(&free_list, ino, i_free); @@ -201,13 +201,13 @@ struct inode *ino; LIST_REMOVE(ino, i_next); if (parent->i_ref == 0 && !HAS_CHILDREN(parent)) { - if (parent->i_parent == NIL_INODE) + if (parent->i_parent == NULL) TAILQ_INSERT_HEAD(&free_list, parent, i_free); else TAILQ_INSERT_TAIL(&free_list, parent, i_free); } - ino->i_parent = NIL_INODE; + ino->i_parent = NULL; } /*===========================================================================* @@ -225,7 +225,7 @@ PUBLIC struct inode *get_free_inode() if (TAILQ_EMPTY(&free_list)) { printf("HGFS: out of inodes!\n"); - return NIL_INODE; + return NULL; } ino = TAILQ_FIRST(&free_list); @@ -235,10 +235,10 @@ PUBLIC struct inode *get_free_inode() assert(!HAS_CHILDREN(ino)); /* If this was a cached inode, free it first. */ - if (ino->i_parent != NIL_INODE) + if (ino->i_parent != NULL) del_dentry(ino); - assert(ino->i_parent == NIL_INODE); + assert(ino->i_parent == NULL); /* Initialize a subset of its fields */ ino->i_gen++; @@ -286,7 +286,7 @@ PUBLIC int do_putnode() struct inode *ino; int count; - if ((ino = find_inode(m_in.REQ_INODE_NR)) == NIL_INODE) + if ((ino = find_inode(m_in.REQ_INODE_NR)) == NULL) return EINVAL; count = m_in.REQ_COUNT; diff --git a/servers/hgfs/hgfs_server/inode.h b/servers/hgfs/hgfs_server/inode.h index 3f5c056e7..092f4d00f 100644 --- a/servers/hgfs/hgfs_server/inode.h +++ b/servers/hgfs/hgfs_server/inode.h @@ -72,7 +72,6 @@ struct inode { #define i_file i_u.u_file #define i_dir i_u.u_dir -#define NIL_INODE ((struct inode *)NULL) #define I_DIR 0x01 /* this inode represents a directory */ #define I_HANDLE 0x02 /* this inode has an open handle */ diff --git a/servers/hgfs/hgfs_server/link.c b/servers/hgfs/hgfs_server/link.c index 0d3e468c8..559235b20 100644 --- a/servers/hgfs/hgfs_server/link.c +++ b/servers/hgfs/hgfs_server/link.c @@ -40,7 +40,7 @@ PUBLIC int do_create() if (!strcmp(name, ".") || !strcmp(name, "..")) return EEXIST; - if ((parent = find_inode(m_in.REQ_INODE_NR)) == NIL_INODE) + if ((parent = find_inode(m_in.REQ_INODE_NR)) == NULL) return EINVAL; if ((r = verify_dentry(parent, name, path, &ino)) != OK) @@ -49,9 +49,9 @@ PUBLIC int do_create() /* Are we going to need a new inode upon success? * Then make sure there is one available before trying anything. */ - if (ino == NIL_INODE || ino->i_ref > 1 || HAS_CHILDREN(ino)) { + if (ino == NULL || ino->i_ref > 1 || HAS_CHILDREN(ino)) { if (!have_free_inode()) { - if (ino != NIL_INODE) + if (ino != NULL) put_inode(ino); return ENFILE; @@ -66,7 +66,7 @@ PUBLIC int do_create() * is wrong with the directory, we'll find out later anyway. */ - if (ino != NIL_INODE) + if (ino != NULL) put_inode(ino); return r; @@ -85,7 +85,7 @@ PUBLIC int do_create() hgfs_close(handle); - if (ino != NIL_INODE) { + if (ino != NULL) { del_dentry(ino); put_inode(ino); @@ -97,7 +97,7 @@ PUBLIC int do_create() /* We do assume that the HGFS open(O_CREAT|O_EXCL) did its job. * If we previousy found an inode, get rid of it now. It's old. */ - if (ino != NIL_INODE) { + if (ino != NULL) { del_dentry(ino); put_inode(ino); @@ -107,7 +107,7 @@ PUBLIC int do_create() */ ino = get_free_inode(); - assert(ino != NIL_INODE); /* we checked before whether we had a free one */ + assert(ino != NULL); /* we checked before whether we had a free one */ ino->i_file = handle; ino->i_flags = I_HANDLE; @@ -146,7 +146,7 @@ PUBLIC int do_mkdir() if (!strcmp(name, ".") || !strcmp(name, "..")) return EEXIST; - if ((parent = find_inode(m_in.REQ_INODE_NR)) == NIL_INODE) + if ((parent = find_inode(m_in.REQ_INODE_NR)) == NULL) return EINVAL; if ((r = verify_dentry(parent, name, path, &ino)) != OK) @@ -156,7 +156,7 @@ PUBLIC int do_mkdir() r = hgfs_mkdir(path, m_in.REQ_MODE); if (r != OK) { - if (ino != NIL_INODE) + if (ino != NULL) put_inode(ino); return r; @@ -165,7 +165,7 @@ PUBLIC int do_mkdir() /* If we thought the new dentry already existed, it was apparently gone * already. Delete it. */ - if (ino != NIL_INODE) { + if (ino != NULL) { del_dentry(ino); put_inode(ino); @@ -250,7 +250,7 @@ PUBLIC int do_unlink() if (!strcmp(name, ".") || !strcmp(name, "..")) return EPERM; - if ((parent = find_inode(m_in.REQ_INODE_NR)) == NIL_INODE) + if ((parent = find_inode(m_in.REQ_INODE_NR)) == NULL) return EINVAL; if ((r = verify_dentry(parent, name, path, &ino)) != OK) @@ -260,14 +260,14 @@ PUBLIC int do_unlink() r = force_remove(path, FALSE /*dir*/); if (r != OK) { - if (ino != NIL_INODE) + if (ino != NULL) put_inode(ino); return r; } /* If a dentry existed for this name, it is gone now. */ - if (ino != NIL_INODE) { + if (ino != NULL) { del_dentry(ino); put_inode(ino); @@ -298,7 +298,7 @@ PUBLIC int do_rmdir() if (!strcmp(name, ".")) return EINVAL; if (!strcmp(name, "..")) return ENOTEMPTY; - if ((parent = find_inode(m_in.REQ_INODE_NR)) == NIL_INODE) + if ((parent = find_inode(m_in.REQ_INODE_NR)) == NULL) return EINVAL; if ((r = verify_dentry(parent, name, path, &ino)) != OK) @@ -308,14 +308,14 @@ PUBLIC int do_rmdir() r = force_remove(path, TRUE /*dir*/); if (r != OK) { - if (ino != NIL_INODE) + if (ino != NULL) put_inode(ino); return r; } /* If a dentry existed for this name, it is gone now. */ - if (ino != NIL_INODE) { + if (ino != NULL) { del_dentry(ino); put_inode(ino); @@ -353,15 +353,15 @@ PUBLIC int do_rename() if (!strcmp(old_name, ".") || !strcmp(old_name, "..") || !strcmp(new_name, ".") || !strcmp(new_name, "..")) return EINVAL; - if ((old_parent = find_inode(m_in.REQ_REN_OLD_DIR)) == NIL_INODE || - (new_parent = find_inode(m_in.REQ_REN_NEW_DIR)) == NIL_INODE) + if ((old_parent = find_inode(m_in.REQ_REN_OLD_DIR)) == NULL || + (new_parent = find_inode(m_in.REQ_REN_NEW_DIR)) == NULL) return EINVAL; if ((r = verify_dentry(old_parent, old_name, old_path, &old_ino)) != OK) return r; if ((r = verify_dentry(new_parent, new_name, new_path, &new_ino)) != OK) { - if (old_ino != NIL_INODE) + if (old_ino != NULL) put_inode(old_ino); return r; @@ -374,9 +374,9 @@ PUBLIC int do_rename() * NULL, or they both refer to the same file. */ if (r != OK || old_ino == new_ino) { - if (old_ino != NIL_INODE) put_inode(old_ino); + if (old_ino != NULL) put_inode(old_ino); - if (new_ino != NIL_INODE) put_inode(new_ino); + if (new_ino != NULL) put_inode(new_ino); return r; } @@ -384,14 +384,14 @@ PUBLIC int do_rename() /* If the new dentry already existed, it has now been overwritten. * Delete the associated inode if we had found one. */ - if (new_ino != NIL_INODE) { + if (new_ino != NULL) { del_dentry(new_ino); put_inode(new_ino); } /* If the old dentry existed, rename it accordingly. */ - if (old_ino != NIL_INODE) { + if (old_ino != NULL) { del_dentry(old_ino); add_dentry(new_parent, new_name, old_ino); diff --git a/servers/hgfs/hgfs_server/lookup.c b/servers/hgfs/hgfs_server/lookup.c index 5c82bdc29..6ad432cbf 100644 --- a/servers/hgfs/hgfs_server/lookup.c +++ b/servers/hgfs/hgfs_server/lookup.c @@ -118,7 +118,7 @@ struct hgfs_attr *attr; /* place to store inode attributes */ pop_path(path); parent = ino->i_parent; - assert(parent != NIL_INODE); + assert(parent != NULL); if ((r = verify_path(path, parent, attr, NULL)) != OK) return r; @@ -154,7 +154,7 @@ struct hgfs_attr *attr; /* place to store inode attributes */ dprintf(("HGFS: lookup_dentry('%s') returned %p\n", name, ino)); - if (ino != NIL_INODE) + if (ino != NULL) r = verify_path(path, ino, attr, &stale); else r = hgfs_getattr(path, attr); @@ -162,10 +162,10 @@ struct hgfs_attr *attr; /* place to store inode attributes */ dprintf(("HGFS: path query returned %d\n", r)); if (r != OK) { - if (ino != NIL_INODE) { + if (ino != NULL) { put_inode(ino); - ino = NIL_INODE; + ino = NULL; } if (!stale) @@ -174,8 +174,8 @@ struct hgfs_attr *attr; /* place to store inode attributes */ dprintf(("HGFS: name '%s'\n", name)); - if (ino == NIL_INODE) { - if ((ino = get_free_inode()) == NIL_INODE) + if (ino == NULL) { + if ((ino = get_free_inode()) == NULL) return ENFILE; dprintf(("HGFS: inode %p ref %d\n", ino, ino->i_ref)); @@ -198,7 +198,7 @@ PUBLIC int do_lookup() */ ino_t dir_ino_nr, root_ino_nr; struct inode *cur_ino, *root_ino; - struct inode *next_ino = NIL_INODE; + struct inode *next_ino = NULL; struct hgfs_attr attr; char buf[PATH_MAX], path[PATH_MAX]; char name[NAME_MAX+1]; @@ -255,7 +255,7 @@ PUBLIC int do_lookup() /* Start the actual lookup. */ dprintf(("HGFS: lookup: got query '%s'\n", buf)); - if ((cur_ino = find_inode(dir_ino_nr)) == NIL_INODE) + if ((cur_ino = find_inode(dir_ino_nr)) == NULL) return EINVAL; attr.a_mask = HGFS_ATTR_MODE | HGFS_ATTR_SIZE; @@ -268,7 +268,7 @@ PUBLIC int do_lookup() if (root_ino_nr > 0) root_ino = find_inode(root_ino_nr); else - root_ino = NIL_INODE; + root_ino = NULL; /* One possible optimization would be to check a path only right before the * first ".." in a row, and at the very end (if still necessary). This would @@ -299,7 +299,7 @@ PUBLIC int do_lookup() if (r != OK) break; - assert(next_ino != NIL_INODE); + assert(next_ino != NULL); put_inode(cur_ino); diff --git a/servers/hgfs/hgfs_server/mount.c b/servers/hgfs/hgfs_server/mount.c index cdcd167b3..e1b83351e 100644 --- a/servers/hgfs/hgfs_server/mount.c +++ b/servers/hgfs/hgfs_server/mount.c @@ -79,7 +79,7 @@ PUBLIC int do_unmount() dprintf(("HGFS: do_unmount\n")); /* Decrease the reference count of the root inode. */ - if ((ino = find_inode(ROOT_INODE_NR)) == NIL_INODE) + if ((ino = find_inode(ROOT_INODE_NR)) == NULL) return EINVAL; put_inode(ino); diff --git a/servers/hgfs/hgfs_server/path.c b/servers/hgfs/hgfs_server/path.c index 654b651a1..20fff640b 100644 --- a/servers/hgfs/hgfs_server/path.c +++ b/servers/hgfs/hgfs_server/path.c @@ -33,7 +33,7 @@ struct inode *ino; plen = strlen(prefix); /* Construct the path right-to-left in a temporary buffer first. */ - for (total = plen; ino != NIL_INODE && !IS_ROOT(ino); ino = ino->i_parent) { + for (total = plen; ino != NULL && !IS_ROOT(ino); ino = ino->i_parent) { len = strlen(ino->i_name); total += len + 1; @@ -49,7 +49,7 @@ struct inode *ino; /* If any of the intermediate inodes has no parent, the final inode is no * longer addressable by name. */ - if (ino == NIL_INODE) + if (ino == NULL) return ENOENT; /* Put the result in the actual buffer. We need the leading slash in the diff --git a/servers/hgfs/hgfs_server/read.c b/servers/hgfs/hgfs_server/read.c index 5a8020920..bd4f8ba53 100644 --- a/servers/hgfs/hgfs_server/read.c +++ b/servers/hgfs/hgfs_server/read.c @@ -28,7 +28,7 @@ PUBLIC int do_read() char *ptr; int r, chunk; - if ((ino = find_inode(m_in.REQ_INODE_NR)) == NIL_INODE) + if ((ino = find_inode(m_in.REQ_INODE_NR)) == NULL) return EINVAL; if (IS_DIR(ino)) return EISDIR; @@ -93,7 +93,7 @@ PUBLIC int do_getdents() attr.a_mask = HGFS_ATTR_MODE; - if ((ino = find_inode(m_in.REQ_INODE_NR)) == NIL_INODE) + if ((ino = find_inode(m_in.REQ_INODE_NR)) == NULL) return EINVAL; if (m_in.REQ_SEEK_POS_HI != 0) return EINVAL; @@ -130,7 +130,7 @@ PUBLIC int do_getdents() } else if (pos == 1) { /* Entry for "..", but only when there is a parent. */ - if (ino->i_parent == NIL_INODE) + if (ino->i_parent == NULL) continue; child = ino->i_parent; @@ -164,11 +164,11 @@ PUBLIC int do_getdents() if (!strcmp(name, ".") || !strcmp(name, "..")) continue; - if ((child = lookup_dentry(ino, name)) == NIL_INODE) { + if ((child = lookup_dentry(ino, name)) == NULL) { child = get_free_inode(); /* We were promised a free inode! */ - assert(child != NIL_INODE); + assert(child != NULL); child->i_flags = MODE_TO_DIRFLAG(attr.a_mode); diff --git a/servers/hgfs/hgfs_server/stat.c b/servers/hgfs/hgfs_server/stat.c index 92f0910eb..2253a11d8 100644 --- a/servers/hgfs/hgfs_server/stat.c +++ b/servers/hgfs/hgfs_server/stat.c @@ -53,7 +53,7 @@ PUBLIC int do_stat() ino_nr = m_in.REQ_INODE_NR; /* Don't increase the inode refcount: it's already open anyway */ - if ((ino = find_inode(ino_nr)) == NIL_INODE) + if ((ino = find_inode(ino_nr)) == NULL) return EINVAL; attr.a_mask = HGFS_ATTR_MODE | HGFS_ATTR_SIZE | HGFS_ATTR_ATIME | @@ -78,7 +78,7 @@ PUBLIC int do_stat() * It's just not worth it. */ stat.st_nlink = 0; - if (ino->i_parent != NIL_INODE) stat.st_nlink++; + if (ino->i_parent != NULL) stat.st_nlink++; if (IS_DIR(ino)) { stat.st_nlink++; if (HAS_CHILDREN(ino)) stat.st_nlink++; @@ -103,7 +103,7 @@ PUBLIC int do_chmod() if (state.read_only) return EROFS; - if ((ino = find_inode(m_in.REQ_INODE_NR)) == NIL_INODE) + if ((ino = find_inode(m_in.REQ_INODE_NR)) == NULL) return EINVAL; if ((r = verify_inode(ino, path, NULL)) != OK) @@ -140,7 +140,7 @@ PUBLIC int do_utime() if (state.read_only) return EROFS; - if ((ino = find_inode(m_in.REQ_INODE_NR)) == NIL_INODE) + if ((ino = find_inode(m_in.REQ_INODE_NR)) == NULL) return EINVAL; if ((r = verify_inode(ino, path, NULL)) != OK) diff --git a/servers/hgfs/hgfs_server/verify.c b/servers/hgfs/hgfs_server/verify.c index 681bd1b6e..cac0f00ca 100644 --- a/servers/hgfs/hgfs_server/verify.c +++ b/servers/hgfs/hgfs_server/verify.c @@ -97,7 +97,7 @@ struct inode **res_ino; /* pointer for addressed inode (or NULL) */ * directory entry, check whether the path to the parent is still valid, and * check whether there is an inode pointed to by the full path. Upon success, * res_ino will contain either the inode for the full path, with increased - * refcount, or NIL_INODE if no such inode exists. + * refcount, or NULL if no such inode exists. */ int r; diff --git a/servers/hgfs/hgfs_server/write.c b/servers/hgfs/hgfs_server/write.c index 05960823d..70401e7f2 100644 --- a/servers/hgfs/hgfs_server/write.c +++ b/servers/hgfs/hgfs_server/write.c @@ -92,7 +92,7 @@ PUBLIC int do_write() if (state.read_only) return EROFS; - if ((ino = find_inode(m_in.REQ_INODE_NR)) == NIL_INODE) + if ((ino = find_inode(m_in.REQ_INODE_NR)) == NULL) return EINVAL; if (IS_DIR(ino)) return EISDIR; @@ -130,7 +130,7 @@ PUBLIC int do_ftrunc() if (state.read_only) return EROFS; - if ((ino = find_inode(m_in.REQ_INODE_NR)) == NIL_INODE) + if ((ino = find_inode(m_in.REQ_INODE_NR)) == NULL) return EINVAL; if (IS_DIR(ino)) return EISDIR; diff --git a/servers/iso9660fs/buf.h b/servers/iso9660fs/buf.h index f61880f64..11070b78b 100644 --- a/servers/iso9660fs/buf.h +++ b/servers/iso9660fs/buf.h @@ -13,7 +13,6 @@ PUBLIC struct buf { /* A block is free if b_dev == NO_DEV. */ -#define NIL_BUF ((struct buf *) 0) /* indicates absence of a buffer */ /* These defs make it possible to use to bp->b_data instead of bp->b.b__data */ #define b_data b.b__data diff --git a/servers/iso9660fs/cache.c b/servers/iso9660fs/cache.c index b9cca4933..4a5166ab3 100644 --- a/servers/iso9660fs/cache.c +++ b/servers/iso9660fs/cache.c @@ -30,7 +30,7 @@ register block_t block; /* which block is wanted? */ { register struct buf *bp, *free_bp; - free_bp = NIL_BUF; + free_bp = NULL; /* Find if the block is already loaded */ for (bp = &buf[0]; bp < &buf[NR_BUFS]; bp++) @@ -49,15 +49,15 @@ register block_t block; /* which block is wanted? */ bp_to_pickup = buf; } - if (free_bp == NIL_BUF && + if (free_bp == NULL && bp_to_pickup == buf && bp_to_pickup->b_count == 0) free_bp = bp_to_pickup; - if (free_bp != NIL_BUF) { + if (free_bp != NULL) { /* Set fields of data structure */ free_bp->b_blocknr = block; - if (read_block(free_bp) != OK) return NIL_BUF; + if (read_block(free_bp) != OK) return NULL; free_bp->b_count = 1; if (bp_to_pickup < &buf[NR_BUFS] - 1) @@ -67,8 +67,8 @@ register block_t block; /* which block is wanted? */ return free_bp; } else { - /* No free blocks. Return NIL_BUF */ - return NIL_BUF; + /* No free blocks. Return NULL */ + return NULL; } } @@ -78,7 +78,7 @@ register block_t block; /* which block is wanted? */ PUBLIC void put_block(bp) register struct buf *bp; /* pointer to the buffer to be released */ { - if (bp == NIL_BUF) return; /* it is easier to check here than in caller */ + if (bp == NULL) return; /* it is easier to check here than in caller */ bp->b_count--; /* there is one use fewer now */ } diff --git a/servers/iso9660fs/inode.c b/servers/iso9660fs/inode.c index 381e8344c..115dd4fb5 100644 --- a/servers/iso9660fs/inode.c +++ b/servers/iso9660fs/inode.c @@ -236,7 +236,7 @@ u32_t address; offset = address % block_size; /* Offset starting from the block */ bp = get_block(block_nr); /* Read the block from the device */ - if (bp == NIL_BUF) + if (bp == NULL) return(NULL); dir = get_free_dir_record(); /* Get a free record */ diff --git a/servers/iso9660fs/path.c b/servers/iso9660fs/path.c index 202fedbef..d28868d18 100644 --- a/servers/iso9660fs/path.c +++ b/servers/iso9660fs/path.c @@ -117,7 +117,7 @@ PUBLIC int search_dir(ldir_ptr,string,numb) pos = ldir_ptr->ext_attr_rec_length; bp = get_block(ldir_ptr->loc_extent_l); - if (bp == NIL_BUF) + if (bp == NULL) return EINVAL; while (pos < v_pri.logical_block_size_l) { diff --git a/servers/iso9660fs/read.c b/servers/iso9660fs/read.c index 960ba0217..aa3b5dc7b 100644 --- a/servers/iso9660fs/read.c +++ b/servers/iso9660fs/read.c @@ -169,7 +169,7 @@ PUBLIC int fs_getdents(void) { while (cur_posd_file_size) { bp = get_block(block); /* Get physical block */ - if (bp == NIL_BUF) { + if (bp == NULL) { release_dir_record(dir); return(EINVAL); } @@ -318,7 +318,7 @@ int *completed; /* number of bytes copied */ bp = get_block(b); /* In all cases, bp now points to a valid buffer. */ - if (bp == NIL_BUF) { + if (bp == NULL) { panic("bp not valid in rw_chunk; this can't happen"); } diff --git a/servers/mfs/buf.h b/servers/mfs/buf.h index cba3abfd1..4491b5132 100644 --- a/servers/mfs/buf.h +++ b/servers/mfs/buf.h @@ -32,7 +32,6 @@ union fsdata_u { /* A block is free if b_dev == NO_DEV. */ -#define NIL_BUF ((struct buf *) 0) /* indicates absence of a buffer */ /* These defs make it possible to use to bp->b_data instead of bp->b.b__data */ #define b_data bp->b__data diff --git a/servers/mfs/cache.c b/servers/mfs/cache.c index 1e07b761f..cdd43390c 100644 --- a/servers/mfs/cache.c +++ b/servers/mfs/cache.c @@ -88,7 +88,7 @@ PUBLIC struct buf *get_block( if (dev != NO_DEV) { b = BUFHASH(block); bp = buf_hash[b]; - while (bp != NIL_BUF) { + while (bp != NULL) { if (bp->b_blocknr == block && bp->b_dev == dev) { /* Block needed has been found. */ if (bp->b_count == 0) rm_lru(bp); @@ -106,7 +106,7 @@ PUBLIC struct buf *get_block( } /* Desired block is not on available chain. Take oldest block ('front'). */ - if ((bp = front) == NIL_BUF) panic("all buffers in use: %d", nr_bufs); + if ((bp = front) == NULL) panic("all buffers in use: %d", nr_bufs); if(bp->b_bytes < fs_block_size) { ASSERT(!bp->bp); @@ -138,7 +138,7 @@ PUBLIC struct buf *get_block( buf_hash[b] = bp->b_hash; } else { /* The block just taken is not on the front of its hash chain. */ - while (prev_ptr->b_hash != NIL_BUF) + while (prev_ptr->b_hash != NULL) if (prev_ptr->b_hash == bp) { prev_ptr->b_hash = bp->b_hash; /* found it */ break; @@ -230,7 +230,7 @@ int block_type; /* INODE_BLOCK, DIRECTORY_BLOCK, or whatever */ * the integrity of the file system (e.g., inode blocks) are written to * disk immediately if they are dirty. */ - if (bp == NIL_BUF) return; /* it is easier to check here than in caller */ + if (bp == NULL) return; /* it is easier to check here than in caller */ bp->b_count--; /* there is one use fewer now */ if (bp->b_count != 0) return; /* block is still in use */ @@ -246,9 +246,9 @@ int block_type; /* INODE_BLOCK, DIRECTORY_BLOCK, or whatever */ /* Block probably won't be needed quickly. Put it on front of chain. * It will be the next block to be evicted from the cache. */ - bp->b_prev = NIL_BUF; + bp->b_prev = NULL; bp->b_next = front; - if (front == NIL_BUF) + if (front == NULL) rear = bp; /* LRU chain was empty */ else front->b_prev = bp; @@ -259,8 +259,8 @@ int block_type; /* INODE_BLOCK, DIRECTORY_BLOCK, or whatever */ * It will not be evicted from the cache for a long time. */ bp->b_prev = rear; - bp->b_next = NIL_BUF; - if (rear == NIL_BUF) + bp->b_next = NULL; + if (rear == NULL) front = bp; else rear->b_next = bp; @@ -532,12 +532,12 @@ struct buf *bp; bufs_in_use++; next_ptr = bp->b_next; /* successor on LRU chain */ prev_ptr = bp->b_prev; /* predecessor on LRU chain */ - if (prev_ptr != NIL_BUF) + if (prev_ptr != NULL) prev_ptr->b_next = next_ptr; else front = next_ptr; /* this block was at front of chain */ - if (next_ptr != NIL_BUF) + if (next_ptr != NULL) next_ptr->b_prev = prev_ptr; else rear = prev_ptr; /* this block was at rear of chain */ @@ -611,8 +611,8 @@ PUBLIC void buf_pool(int new_nr_bufs) bp->bp = NULL; bp->b_bytes = 0; } - buf[0].b_prev = NIL_BUF; - buf[nr_bufs - 1].b_next = NIL_BUF; + buf[0].b_prev = NULL; + buf[nr_bufs - 1].b_next = NULL; for (bp = &buf[0]; bp < &buf[nr_bufs]; bp++) bp->b_hash = bp->b_next; buf_hash[0] = front; diff --git a/servers/mfs/inode.c b/servers/mfs/inode.c index 80201e33b..e574fe613 100644 --- a/servers/mfs/inode.c +++ b/servers/mfs/inode.c @@ -152,7 +152,7 @@ PUBLIC struct inode *get_inode( /* Inode is not on the hash, get a free one */ if (TAILQ_EMPTY(&unused_inodes)) { err_code = ENFILE; - return(NIL_INODE); + return(NULL); } rip = TAILQ_FIRST(&unused_inodes); @@ -201,7 +201,7 @@ PUBLIC struct inode *find_inode( } } - return(NIL_INODE); + return(NULL); } @@ -216,7 +216,7 @@ register struct inode *rip; /* pointer to inode to be released */ * return it to the pool of available inodes. */ - if (rip == NIL_INODE) return; /* checking here is easier than in caller */ + if (rip == NULL) return; /* checking here is easier than in caller */ if (rip->i_count < 1) panic("put_inode: i_count already below 1: %d", rip->i_count); @@ -261,7 +261,7 @@ PUBLIC struct inode *alloc_inode(dev_t dev, mode_t bits) sp = get_super(dev); /* get pointer to super_block */ if (sp->s_rd_only) { /* can't allocate an inode on a read only device. */ err_code = EROFS; - return(NIL_INODE); + return(NULL); } /* Acquire an inode from the bit map. */ @@ -271,13 +271,13 @@ PUBLIC struct inode *alloc_inode(dev_t dev, mode_t bits) major = (int) (sp->s_dev >> MAJOR) & BYTE; minor = (int) (sp->s_dev >> MINOR) & BYTE; printf("Out of i-nodes on device %d/%d\n", major, minor); - return(NIL_INODE); + return(NULL); } sp->s_isearch = b; /* next time start here */ inumb = (int) b; /* be careful not to pass unshort as param */ /* Try to acquire a slot in the inode table. */ - if ((rip = get_inode(NO_DEV, inumb)) == NIL_INODE) { + if ((rip = get_inode(NO_DEV, inumb)) == NULL) { /* No inode table slots available. Free the inode just allocated. */ free_bit(sp, IMAP, b); } else { diff --git a/servers/mfs/inode.h b/servers/mfs/inode.h index 2a22026e1..87c4a9f89 100644 --- a/servers/mfs/inode.h +++ b/servers/mfs/inode.h @@ -53,7 +53,6 @@ EXTERN LIST_HEAD(inodelist, inode) hash_inodes[INODE_HASH_SIZE]; EXTERN unsigned int inode_cache_hit; EXTERN unsigned int inode_cache_miss; -#define NIL_INODE (struct inode *) 0 /* indicates absence of inode slot */ /* Field values. Note that CLEAN and DIRTY are defined in "const.h" */ #define NO_SEEK 0 /* i_seek = NO_SEEK if last op was not SEEK */ diff --git a/servers/mfs/link.c b/servers/mfs/link.c index 861854865..2056be7d3 100644 --- a/servers/mfs/link.c +++ b/servers/mfs/link.c @@ -46,7 +46,7 @@ PUBLIC int fs_link() MFS_NUL(string, len, sizeof(string)); /* Temporarily open the file. */ - if( (rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) + if( (rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL) return(EINVAL); /* Check to see if the file has maximum number of links already. */ @@ -66,12 +66,12 @@ PUBLIC int fs_link() } /* Temporarily open the last dir */ - if( (ip = get_inode(fs_dev, fs_m_in.REQ_DIR_INO)) == NIL_INODE) + if( (ip = get_inode(fs_dev, fs_m_in.REQ_DIR_INO)) == NULL) return(EINVAL); /* If 'name2' exists in full (even if no space) set 'r' to error. */ if (r == OK) { - if((new_ip = advance(ip, string, IGN_PERM)) == NIL_INODE) { + if((new_ip = advance(ip, string, IGN_PERM)) == NULL) { r = err_code; if(r == ENOENT) r = OK; @@ -122,7 +122,7 @@ PUBLIC int fs_unlink() MFS_NUL(string, len, sizeof(string)); /* Temporarily open the dir. */ - if( (rldirp = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) + if( (rldirp = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL) return(EINVAL); /* The last directory exists. Does the file also exist? */ @@ -175,7 +175,7 @@ PUBLIC int fs_rdlink() if (copylen <= 0) return(EINVAL); /* Temporarily open the file. */ - if( (rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) + if( (rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL) return(EINVAL); if(!S_ISLNK(rip->i_mode)) @@ -229,8 +229,8 @@ char dir_name[NAME_MAX]; /* name of directory to be removed */ /* Unlink . and .. from the dir. The super user can link and unlink any dir, * so don't make too many assumptions about them. */ - (void) unlink_file(rip, NIL_INODE, dot1); - (void) unlink_file(rip, NIL_INODE, dot2); + (void) unlink_file(rip, NULL, dot1); + (void) unlink_file(rip, NULL, dot2); return(OK); } @@ -240,20 +240,20 @@ char dir_name[NAME_MAX]; /* name of directory to be removed */ *===========================================================================*/ PRIVATE int unlink_file(dirp, rip, file_name) struct inode *dirp; /* parent directory of file */ -struct inode *rip; /* inode of file, may be NIL_INODE too. */ +struct inode *rip; /* inode of file, may be NULL too. */ char file_name[NAME_MAX]; /* name of file to be removed */ { -/* Unlink 'file_name'; rip must be the inode of 'file_name' or NIL_INODE. */ +/* Unlink 'file_name'; rip must be the inode of 'file_name' or NULL. */ ino_t numb; /* inode number */ int r; - /* If rip is not NIL_INODE, it is used to get faster access to the inode. */ - if (rip == NIL_INODE) { + /* If rip is not NULL, it is used to get faster access to the inode. */ + if (rip == NULL) { /* Search for file in directory and try to get its inode. */ err_code = search_dir(dirp, file_name, &numb, LOOK_UP, IGN_PERM); if (err_code == OK) rip = get_inode(dirp->i_dev, (int) numb); - if (err_code != OK || rip == NIL_INODE) return(err_code); + if (err_code != OK || rip == NULL) return(err_code); } else { dup_inode(rip); /* inode will be returned with put_inode */ } @@ -302,7 +302,7 @@ PUBLIC int fs_rename() MFS_NUL(new_name, len, sizeof(new_name)); /* Get old dir inode */ - if( (old_dirp = get_inode(fs_dev, fs_m_in.REQ_REN_OLD_DIR)) == NIL_INODE) + if( (old_dirp = get_inode(fs_dev, fs_m_in.REQ_REN_OLD_DIR)) == NULL) return(err_code); old_ip = advance(old_dirp, old_name, IGN_PERM); @@ -315,7 +315,7 @@ PUBLIC int fs_rename() } /* Get new dir inode */ - if( (new_dirp = get_inode(fs_dev, fs_m_in.REQ_REN_NEW_DIR)) == NIL_INODE) + if( (new_dirp = get_inode(fs_dev, fs_m_in.REQ_REN_NEW_DIR)) == NULL) r = err_code; new_ip = advance(new_dirp, new_name, IGN_PERM); /* not required to exist */ @@ -326,7 +326,7 @@ PUBLIC int fs_rename() r = EBUSY; } - if(old_ip != NIL_INODE) + if(old_ip != NULL) odir = ((old_ip->i_mode & I_TYPE) == I_DIRECTORY); /* TRUE iff dir */ else odir = FALSE; /* FIXME: is this a safe default? */ @@ -360,7 +360,7 @@ PUBLIC int fs_rename() break; } new_superdirp = next_new_superdirp; - if(new_superdirp == NIL_INODE) { + if(new_superdirp == NULL) { /* Missing ".." entry. Assume the worst. */ r = EINVAL; break; @@ -377,7 +377,7 @@ PUBLIC int fs_rename() if(old_dirp->i_dev != new_dirp->i_dev) r = EXDEV; */ /* Some tests apply only if the new path exists. */ - if(new_ip == NIL_INODE) { + if(new_ip == NULL) { /* don't rename a file with a file system mounted on it. if (old_ip->i_dev != old_dirp->i_dev) r = EXDEV;*/ if(odir && new_dirp->i_nlinks >= @@ -407,7 +407,7 @@ PUBLIC int fs_rename() * is completely full]. */ if(r == OK) { - if(new_ip != NIL_INODE) { + if(new_ip != NULL) { /* There is already an entry for 'new'. Try to remove it. */ if(odir) r = remove_dir(new_dirp, new_ip, new_name); @@ -444,7 +444,7 @@ PUBLIC int fs_rename() if(r == OK && odir && !same_pdir) { /* Update the .. entry in the directory (still points to old_dirp).*/ numb = new_dirp->i_num; - (void) unlink_file(old_ip, NIL_INODE, dot2); + (void) unlink_file(old_ip, NULL, dot2); if(search_dir(old_ip, dot2, &numb, ENTER, IGN_PERM) == OK) { /* New link created. */ new_dirp->i_nlinks++; @@ -470,7 +470,7 @@ PUBLIC int fs_ftrunc(void) off_t start, end; int r; - if( (rip = find_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) + if( (rip = find_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL) return(EINVAL); start = fs_m_in.REQ_TRC_START_LO; @@ -655,7 +655,7 @@ off_t len; if(!len) return; /* no zeroing to be done. */ if( (b = read_map(rip, pos)) == NO_BLOCK) return; while (len > 0) { - if( (bp = get_block(rip->i_dev, b, NORMAL)) == NIL_BUF) + if( (bp = get_block(rip->i_dev, b, NORMAL)) == NULL) panic("zerozone_range: no block"); offset = pos % block_size; bytes = block_size - offset; diff --git a/servers/mfs/main.c b/servers/mfs/main.c index ec3fcb42b..e9a5224b6 100644 --- a/servers/mfs/main.c +++ b/servers/mfs/main.c @@ -63,7 +63,7 @@ PUBLIC int main(int argc, char *argv[]) fs_m_out.m_type = error; reply(src, &fs_m_out); - if (error == OK && rdahed_inode != NIL_INODE) + if (error == OK && rdahed_inode != NULL) read_ahead(); /* do block read ahead */ } diff --git a/servers/mfs/mount.c b/servers/mfs/mount.c index 8a84497cd..0c47a3cf2 100644 --- a/servers/mfs/mount.c +++ b/servers/mfs/mount.c @@ -82,14 +82,14 @@ PUBLIC int fs_readsuper() set_blocksize(superblock.s_block_size); /* Get the root inode of the mounted file system. */ - if( (root_ip = get_inode(fs_dev, ROOT_INODE)) == NIL_INODE) { + if( (root_ip = get_inode(fs_dev, ROOT_INODE)) == NULL) { printf("MFS: couldn't get root inode\n"); superblock.s_dev = NO_DEV; dev_close(driver_e, fs_dev); return(EINVAL); } - if(root_ip != NIL_INODE && root_ip->i_mode == 0) { + if(root_ip != NULL && root_ip->i_mode == 0) { printf("%s:%d zero mode for root inode?\n", __FILE__, __LINE__); put_inode(root_ip); superblock.s_dev = NO_DEV; @@ -124,7 +124,7 @@ PUBLIC int fs_mountpoint() mode_t bits; /* Temporarily open the file. */ - if( (rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) + if( (rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL) return(EINVAL); @@ -159,7 +159,7 @@ PUBLIC int fs_unmount() for (rip = &inode[0]; rip < &inode[NR_INODES]; rip++) if (rip->i_count > 0 && rip->i_dev == fs_dev) count += rip->i_count; - if ((root_ip = find_inode(fs_dev, ROOT_INODE)) == NIL_INODE) { + if ((root_ip = find_inode(fs_dev, ROOT_INODE)) == NULL) { printf("MFS: couldn't find root inode. Unmount failed.\n"); panic("MFS: couldn't find root inode: %d", EINVAL); return(EINVAL); diff --git a/servers/mfs/open.c b/servers/mfs/open.c index 44abd8930..d403a6403 100644 --- a/servers/mfs/open.c +++ b/servers/mfs/open.c @@ -42,7 +42,7 @@ PUBLIC int fs_create() MFS_NUL(lastc, len, sizeof(lastc)); /* Get last directory inode (i.e., directory that will hold the new inode) */ - if ((ldirp = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) + if ((ldirp = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL) return(ENOENT); /* Create a new inode by calling new_node(). */ @@ -93,7 +93,7 @@ PUBLIC int fs_mknod() caller_gid = fs_m_in.REQ_GID; /* Get last directory inode */ - if((ldirp = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) + if((ldirp = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL) return(ENOENT); /* Try to create the new node */ @@ -127,13 +127,13 @@ PUBLIC int fs_mkdir() caller_gid = fs_m_in.REQ_GID; /* Get last directory inode */ - if((ldirp = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) + if((ldirp = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL) return(ENOENT); /* Next make the inode. If that fails, return error code. */ rip = new_node(ldirp, lastc, fs_m_in.REQ_MODE, (zone_t) 0); - if(rip == NIL_INODE || err_code == EEXIST) { + if(rip == NULL || err_code == EEXIST) { put_inode(rip); /* can't make dir: it already exists */ put_inode(ldirp); return(err_code); @@ -194,7 +194,7 @@ PUBLIC int fs_slink() MFS_NUL(string, len, sizeof(string)); /* Temporarily open the dir. */ - if( (ldirp = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) + if( (ldirp = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL) return(EINVAL); /* Create the inode for the symlink. */ @@ -204,7 +204,7 @@ PUBLIC int fs_slink() /* Allocate a disk block for the contents of the symlink. * Copy contents of symlink (the name pointed to) into first disk block. */ if( (r = err_code) == OK) { - r = (bp = new_block(sip, (off_t) 0)) == NIL_BUF ? err_code : + r = (bp = new_block(sip, (off_t) 0)) == NULL ? err_code : sys_safecopyfrom(FS_PROC_NR, fs_m_in.REQ_GRANT3, 0, (vir_bytes) bp->b_data, (vir_bytes) fs_m_in.REQ_MEM_SIZE, D); @@ -225,7 +225,7 @@ PUBLIC int fs_slink() } } - put_block(bp, DIRECTORY_BLOCK); /* put_block() accepts NIL_BUF. */ + put_block(bp, DIRECTORY_BLOCK); /* put_block() accepts NULL. */ if(r != OK) { sip->i_nlinks = 0; @@ -236,7 +236,7 @@ PUBLIC int fs_slink() } } - /* put_inode() accepts NIL_INODE as a noop, so the below are safe. */ + /* put_inode() accepts NULL as a noop, so the below are safe. */ put_inode(sip); put_inode(ldirp); @@ -253,7 +253,7 @@ PRIVATE struct inode *new_node(struct inode *ldirp, * In all cases it allocates a new inode, makes a directory entry for it in * the ldirp directory with string name, and initializes it. * It returns a pointer to the inode if it can do this; - * otherwise it returns NIL_INODE. It always sets 'err_code' + * otherwise it returns NULL. It always sets 'err_code' * to an appropriate value (OK or an error code). * * The parsed path rest is returned in 'parsed' if parsed is nonzero. It @@ -272,14 +272,14 @@ PRIVATE struct inode *new_node(struct inode *ldirp, /* New entry is a directory, alas we can't give it a ".." */ put_inode(rip); err_code = EMLINK; - return(NIL_INODE); + return(NULL); } - if ( rip == NIL_INODE && err_code == ENOENT) { + if ( rip == NULL && err_code == ENOENT) { /* Last path component does not exist. Make new directory entry. */ - if ( (rip = alloc_inode((ldirp)->i_dev, bits)) == NIL_INODE) { + if ( (rip = alloc_inode((ldirp)->i_dev, bits)) == NULL) { /* Can't creat new inode: out of inodes. */ - return(NIL_INODE); + return(NULL); } /* Force inode to the disk before making directory entry to make @@ -296,14 +296,14 @@ PRIVATE struct inode *new_node(struct inode *ldirp, rip->i_dirt = DIRTY; /* dirty inodes are written out */ put_inode(rip); /* this call frees the inode */ err_code = r; - return(NIL_INODE); + return(NULL); } } else if (err_code == EENTERMOUNT || err_code == ELEAVEMOUNT) { r = EEXIST; } else { /* Either last component exists, or there is some problem. */ - if (rip != NIL_INODE) + if (rip != NULL) r = EEXIST; else r = err_code; @@ -322,7 +322,7 @@ PUBLIC int fs_inhibread() { struct inode *rip; - if((rip = find_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) + if((rip = find_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL) return(EINVAL); /* inhibit read ahead */ diff --git a/servers/mfs/path.c b/servers/mfs/path.c index 531d24927..7e555e93e 100644 --- a/servers/mfs/path.c +++ b/servers/mfs/path.c @@ -163,7 +163,7 @@ int *symlinkp; *symlinkp = 0; /* Find starting inode inode according to the request message */ - if((rip = find_inode(fs_dev, dir_ino)) == NIL_INODE) + if((rip = find_inode(fs_dev, dir_ino)) == NULL) return(ENOENT); /* If dir has been removed return ENOENT. */ @@ -310,7 +310,7 @@ char *suffix; /* current remaining path. Has to point in the struct buf *bp; /* buffer containing link text */ char *sp; /* start of link text */ - bp = NIL_BUF; + bp = NULL; if ((blink = read_map(rip, (off_t) 0)) == NO_BLOCK) return(EIO); @@ -379,20 +379,20 @@ int chk_perm; /* check permissions when string is looked up*/ /* If 'string' is empty, return an error. */ if (string[0] == '\0') { err_code = ENOENT; - return(NIL_INODE); + return(NULL); } - /* Check for NIL_INODE. */ - if (dirp == NIL_INODE) return(NIL_INODE); + /* Check for NULL. */ + if (dirp == NULL) return(NULL); /* If 'string' is not present in the directory, signal error. */ if ( (err_code = search_dir(dirp, string, &numb, LOOK_UP, chk_perm)) != OK) { - return(NIL_INODE); + return(NULL); } /* The component has been found in the directory. Get inode. */ - if ( (rip = get_inode(dirp->i_dev, (int) numb)) == NIL_INODE) { - return(NIL_INODE); + if ( (rip = get_inode(dirp->i_dev, (int) numb)) == NULL) { + return(NULL); } /* The following test is for "mountpoint/.." where mountpoint is a @@ -420,7 +420,7 @@ int chk_perm; /* check permissions when string is looked up*/ * mounted file system. The super_block provides the linkage between the * inode mounted on and the root directory of the mounted file system. */ - if (rip != NIL_INODE && rip->i_mountpoint) { + if (rip != NULL && rip->i_mountpoint) { /* Mountpoint encountered, report it */ err_code = EENTERMOUNT; } @@ -604,7 +604,7 @@ int check_permissions; /* check permissions when flag is !IS_EMPTY */ if (e_hit == FALSE) { /* directory is full and no room left in last block */ new_slots++; /* increase directory size by 1 entry */ if (new_slots == 0) return(EFBIG); /* dir size limited by slot count */ - if ( (bp = new_block(ldir_ptr, ldir_ptr->i_size)) == NIL_BUF) + if ( (bp = new_block(ldir_ptr, ldir_ptr->i_size)) == NULL) return(err_code); dp = &bp->b_dir[0]; extended = 1; diff --git a/servers/mfs/protect.c b/servers/mfs/protect.c index 6d4d5c4ef..605e952db 100644 --- a/servers/mfs/protect.c +++ b/servers/mfs/protect.c @@ -19,7 +19,7 @@ PUBLIC int fs_chmod() register struct inode *rip; /* Temporarily open the file. */ - if( (rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) + if( (rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL) return(EINVAL); /* Now make the change. Clear setgid bit if file is not in caller's grp */ @@ -44,7 +44,7 @@ PUBLIC int fs_chown() register int r; /* Temporarily open the file. */ - if( (rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) + if( (rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL) return(EINVAL); /* Not permitted to change the owner of a file on a read-only file sys. */ diff --git a/servers/mfs/read.c b/servers/mfs/read.c index 5a747d0f2..55e47a6b2 100644 --- a/servers/mfs/read.c +++ b/servers/mfs/read.c @@ -34,7 +34,7 @@ PUBLIC int fs_readwrite(void) r = OK; /* Find the inode referred */ - if ((rip = find_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) + if ((rip = find_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL) return(EINVAL); mode_word = rip->i_mode & I_TYPE; @@ -240,7 +240,7 @@ int *completed; /* number of bytes copied */ zero_block(bp); } else { /* Writing to a nonexistent block. Create and enter in inode.*/ - if ((bp= new_block(rip, ex64lo(position))) == NIL_BUF) + if ((bp= new_block(rip, ex64lo(position))) == NULL) return(err_code); } } else if (rw_flag == READING) { @@ -258,7 +258,7 @@ int *completed; /* number of bytes copied */ } /* In all cases, bp now points to a valid buffer. */ - if (bp == NIL_BUF) + if (bp == NULL) panic("bp not valid in rw_chunk; this can't happen"); if (rw_flag == WRITING && chunk != block_size && !block_spec && @@ -366,8 +366,8 @@ int index; /* index into *bp */ struct super_block *sp; zone_t zone; /* V2 zones are longs (shorts in V1) */ - if(bp == NIL_BUF) - panic("rd_indir() on NIL_BUF"); + if(bp == NULL) + panic("rd_indir() on NULL"); sp = get_super(bp->b_dev); /* need super block to find file sys type */ @@ -401,7 +401,7 @@ PUBLIC void read_ahead() rip = rdahed_inode; /* pointer to inode to read ahead from */ block_size = get_block_size(rip->i_dev); - rdahed_inode = NIL_INODE; /* turn off read ahead */ + rdahed_inode = NULL; /* turn off read ahead */ if ( (b = read_map(rip, rdahedpos)) == NO_BLOCK) return; /* at EOF */ bp = rahead(rip, b, cvul64(rdahedpos), block_size); put_block(bp, PARTIAL_DATA_BLOCK); @@ -560,7 +560,7 @@ PUBLIC int fs_getdents(void) if(pos % DIR_ENTRY_SIZE) return(ENOENT); - if( (rip = get_inode(fs_dev, ino)) == NIL_INODE) + if( (rip = get_inode(fs_dev, ino)) == NULL) return(EINVAL); block_size = rip->i_sp->s_block_size; diff --git a/servers/mfs/stadir.c b/servers/mfs/stadir.c index 1906b16b8..25ad60aac 100644 --- a/servers/mfs/stadir.c +++ b/servers/mfs/stadir.c @@ -62,7 +62,7 @@ PUBLIC int fs_fstatfs() struct inode *rip; int r; - if((rip = find_inode(fs_dev, ROOT_INODE)) == NIL_INODE) + if((rip = find_inode(fs_dev, ROOT_INODE)) == NULL) return(EINVAL); st.f_bsize = rip->i_sp->s_block_size; @@ -83,7 +83,7 @@ PUBLIC int fs_stat() register int r; /* return value */ register struct inode *rip; /* target inode */ - if ((rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) + if ((rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL) return(EINVAL); r = stat_inode(rip, fs_m_in.m_source, fs_m_in.REQ_GRANT); diff --git a/servers/mfs/super.h b/servers/mfs/super.h index 4336bfd90..2fbba027e 100644 --- a/servers/mfs/super.h +++ b/servers/mfs/super.h @@ -57,6 +57,5 @@ EXTERN struct super_block { char s_is_root; } superblock; -#define NIL_SUPER (struct super_block *) 0 #define IMAP 0 /* operating on the inode bit map */ #define ZMAP 1 /* operating on the zone bit map */ diff --git a/servers/mfs/time.c b/servers/mfs/time.c index 7feb193b7..a3a478c82 100644 --- a/servers/mfs/time.c +++ b/servers/mfs/time.c @@ -14,7 +14,7 @@ PUBLIC int fs_utime() register int r; /* Temporarily open the file. */ - if( (rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NIL_INODE) + if( (rip = get_inode(fs_dev, fs_m_in.REQ_INODE_NR)) == NULL) return(EINVAL); /* Only the owner of a file or the super_user can change its time. */ diff --git a/servers/mfs/write.c b/servers/mfs/write.c index 7a66f52f7..21a436b28 100644 --- a/servers/mfs/write.c +++ b/servers/mfs/write.c @@ -42,7 +42,7 @@ int op; /* special actions */ zone_t z, z1, z2 = NO_ZONE, old_zone; register block_t b; long excess, zone; - struct buf *bp_dindir = NIL_BUF, *bp = NIL_BUF; + struct buf *bp_dindir = NULL, *bp = NULL; rip->i_dirt = DIRTY; /* inode will be changed */ scale = rip->i_sp->s_log_zone_size; /* for zone-block conversion */ @@ -119,7 +119,7 @@ int op; /* special actions */ new_ind = TRUE; /* If double ind, it is dirty. */ - if (bp_dindir != NIL_BUF) bp_dindir->b_dirt = DIRTY; + if (bp_dindir != NULL) bp_dindir->b_dirt = DIRTY; if (z1 == NO_ZONE) { /* Release dbl indirect blk. */ put_block(bp_dindir, INDIRECT_BLOCK); @@ -195,8 +195,8 @@ zone_t zone; /* zone to write */ struct super_block *sp; - if(bp == NIL_BUF) - panic("wr_indir() on NIL_BUF"); + if(bp == NULL) + panic("wr_indir() on NULL"); sp = get_super(bp->b_dev); /* need super block to find file sys type */ @@ -306,12 +306,12 @@ off_t position; /* file pointer */ /* searched before, start from last find */ z = rip->i_zsearch; } - if ( (z = alloc_zone(rip->i_dev, z)) == NO_ZONE) return(NIL_BUF); + if ( (z = alloc_zone(rip->i_dev, z)) == NO_ZONE) return(NULL); rip->i_zsearch = z; /* store for next lookup */ if ( (r = write_map(rip, position, z, 0)) != OK) { free_zone(rip->i_dev, z); err_code = r; - return(NIL_BUF); + return(NULL); } /* If we are not writing at EOF, clear the zone, just to be safe. */ diff --git a/servers/pfs/buf.h b/servers/pfs/buf.h index 143462689..c25ac55b0 100644 --- a/servers/pfs/buf.h +++ b/servers/pfs/buf.h @@ -16,7 +16,6 @@ struct buf { /* A block is free if b_dev == NO_DEV. */ -#define NIL_BUF ((struct buf *) 0) /* indicates absence of a buffer */ #define BUFHASH(b) ((b) % NR_BUFS) diff --git a/servers/pfs/buffer.c b/servers/pfs/buffer.c index 1336bde9d..6215e436a 100644 --- a/servers/pfs/buffer.c +++ b/servers/pfs/buffer.c @@ -14,8 +14,8 @@ PUBLIC void buf_pool(void) { /* Initialize the buffer pool. */ - front = NIL_BUF; - rear = NIL_BUF; + front = NULL; + rear = NULL; } @@ -27,7 +27,7 @@ PUBLIC struct buf *get_block(dev_t dev, ino_t inum) { struct buf *bp = front; - while(bp != NIL_BUF) { + while(bp != NULL) { if (bp->b_dev == dev && bp->b_num == inum) { bp->b_count++; return(bp); @@ -51,7 +51,7 @@ PUBLIC struct buf *new_block(dev_t dev, ino_t inum) bp = malloc(sizeof(struct buf)); if (bp == NULL) { err_code = ENOSPC; - return(NIL_BUF); + return(NULL); } bp->b_num = inum; bp->b_dev = dev; @@ -60,14 +60,14 @@ PUBLIC struct buf *new_block(dev_t dev, ino_t inum) memset(bp->b_data, 0 , PIPE_BUF); /* Add at the end of the buffer */ - if (front == NIL_BUF) { /* Empty list? */ + if (front == NULL) { /* Empty list? */ front = bp; - bp->b_prev = NIL_BUF; + bp->b_prev = NULL; } else { rear->b_next = bp; bp->b_prev = rear; } - bp->b_next = NIL_BUF; + bp->b_next = NULL; rear = bp; return(bp); @@ -82,18 +82,18 @@ PUBLIC void put_block(dev_t dev, ino_t inum) struct buf *bp; bp = get_block(dev, inum); - if (bp == NIL_BUF) return; /* We didn't find the block. Nothing to put. */ + if (bp == NULL) return; /* We didn't find the block. Nothing to put. */ bp->b_count--; /* Compensate for above 'get_block'. */ if (--bp->b_count > 0) return; /* Cut bp out of the loop */ - if (bp->b_prev == NIL_BUF) + if (bp->b_prev == NULL) front = bp->b_next; else bp->b_prev->b_next = bp->b_next; - if (bp->b_next == NIL_BUF) + if (bp->b_next == NULL) rear = bp->b_prev; else bp->b_next->b_prev = bp->b_prev; diff --git a/servers/pfs/inode.c b/servers/pfs/inode.c index d4092f149..254c786a9 100644 --- a/servers/pfs/inode.c +++ b/servers/pfs/inode.c @@ -148,7 +148,7 @@ PUBLIC struct inode *get_inode( /* Inode is not on the hash, get a free one */ if (TAILQ_EMPTY(&unused_inodes)) { err_code = ENFILE; - return(NIL_INODE); + return(NULL); } rip = TAILQ_FIRST(&unused_inodes); @@ -192,7 +192,7 @@ int numb; /* inode number (ANSI: may not be unshort) */ } } - return(NIL_INODE); + return(NULL); } @@ -207,7 +207,7 @@ register struct inode *rip; /* pointer to inode to be released */ * return it to the pool of available inodes. */ - if (rip == NIL_INODE) return; /* checking here is easier than in caller */ + if (rip == NULL) return; /* checking here is easier than in caller */ if (rip->i_count < 1) panic("put_inode: i_count already below 1: %d", rip->i_count); @@ -252,13 +252,13 @@ PUBLIC struct inode *alloc_inode(dev_t dev, mode_t bits) if (b == NO_BIT) { err_code = ENOSPC; printf("PipeFS is out of inodes\n"); - return(NIL_INODE); + return(NULL); } i_num = (ino_t) b; /* Try to acquire a slot in the inode table. */ - if ((rip = get_inode(dev, i_num)) == NIL_INODE) { + if ((rip = get_inode(dev, i_num)) == NULL) { /* No inode table slots available. Free the inode if just allocated.*/ if (dev == NO_DEV) free_bit(b); } else { diff --git a/servers/pfs/inode.h b/servers/pfs/inode.h index 605cbee82..06590fbcf 100644 --- a/servers/pfs/inode.h +++ b/servers/pfs/inode.h @@ -32,5 +32,4 @@ EXTERN TAILQ_HEAD(unused_inodes_t, inode) unused_inodes; /* inode hashtable */ EXTERN LIST_HEAD(inodelist, inode) hash_inodes[INODE_HASH_SIZE]; -#define NIL_INODE (struct inode *) 0 /* indicates absence of inode slot */ diff --git a/servers/pfs/link.c b/servers/pfs/link.c index 71208f560..da71594f7 100644 --- a/servers/pfs/link.c +++ b/servers/pfs/link.c @@ -15,7 +15,7 @@ PUBLIC int fs_ftrunc(void) inumb = fs_m_in.REQ_INODE_NR; - if( (rip = find_inode(inumb)) == NIL_INODE) return(EINVAL); + if( (rip = find_inode(inumb)) == NULL) return(EINVAL); start = fs_m_in.REQ_TRC_START_LO; end = fs_m_in.REQ_TRC_END_LO; diff --git a/servers/pfs/open.c b/servers/pfs/open.c index 4eecf72cd..f015ea1f7 100644 --- a/servers/pfs/open.c +++ b/servers/pfs/open.c @@ -24,7 +24,7 @@ PUBLIC int fs_newnode() dev = fs_m_in.REQ_DEV; /* Try to allocate the inode */ - if( (rip = alloc_inode(dev, bits) ) == NIL_INODE) return(err_code); + if( (rip = alloc_inode(dev, bits) ) == NULL) return(err_code); switch (bits & S_IFMT) { case S_IFBLK: @@ -32,7 +32,7 @@ PUBLIC int fs_newnode() rip->i_rdev = dev; /* Major/minor dev numbers */ break; case S_IFIFO: - if ((get_block(dev, rip->i_num)) == NIL_BUF) + if ((get_block(dev, rip->i_num)) == NULL) r = EIO; break; default: diff --git a/servers/pfs/read.c b/servers/pfs/read.c index bd763abe4..c2ee12b75 100644 --- a/servers/pfs/read.c +++ b/servers/pfs/read.c @@ -26,7 +26,7 @@ PUBLIC int fs_readwrite(void) rw_flag = (fs_m_in.m_type == REQ_READ ? READING : WRITING); /* Find the inode referred */ - if ((rip = find_inode(inumb)) == NIL_INODE) return(EINVAL); + if ((rip = find_inode(inumb)) == NULL) return(EINVAL); mode_word = rip->i_mode & I_TYPE; if (mode_word != I_NAMED_PIPE) return(EIO); @@ -44,8 +44,8 @@ PUBLIC int fs_readwrite(void) } /* Mark inode in use */ - if ((get_inode(rip->i_dev, rip->i_num)) == NIL_INODE) return(err_code); - if ((bp = get_block(rip->i_dev, rip->i_num)) == NIL_BUF) return(err_code); + if ((get_inode(rip->i_dev, rip->i_num)) == NULL) return(err_code); + if ((bp = get_block(rip->i_dev, rip->i_num)) == NULL) return(err_code); if (rw_flag == READING) { /* Copy a chunk from the block buffer to user space. */ diff --git a/servers/pfs/stadir.c b/servers/pfs/stadir.c index 2eaec09db..bd6a267cf 100644 --- a/servers/pfs/stadir.c +++ b/servers/pfs/stadir.c @@ -52,7 +52,7 @@ PUBLIC int fs_stat() register int r; /* return value */ register struct inode *rip; /* target inode */ - if( (rip = find_inode(fs_m_in.REQ_INODE_NR)) == NIL_INODE) return(EINVAL); + if( (rip = find_inode(fs_m_in.REQ_INODE_NR)) == NULL) return(EINVAL); get_inode(rip->i_dev, rip->i_num); /* mark inode in use */ r = stat_inode(rip, fs_m_in.m_source, fs_m_in.REQ_GRANT); put_inode(rip); /* release the inode */ diff --git a/servers/pm/misc.c b/servers/pm/misc.c index b5c7c0595..18e3ebac6 100644 --- a/servers/pm/misc.c +++ b/servers/pm/misc.c @@ -296,7 +296,7 @@ PUBLIC int do_getprocnr() #endif if (m_in.pid >= 0) { /* lookup process by pid */ - if ((rmp = find_proc(m_in.pid)) != NIL_MPROC) { + if ((rmp = find_proc(m_in.pid)) != NULL) { mp->mp_reply.PM_ENDPT = rmp->mp_endpoint; #if 0 printf("PM: pid result: %d\n", rmp->mp_endpoint); @@ -422,7 +422,7 @@ PUBLIC int do_getsetpriority() if (arg_who == 0) rmp = mp; else - if ((rmp = find_proc(arg_who)) == NIL_MPROC) + if ((rmp = find_proc(arg_who)) == NULL) return(ESRCH); if (mp->mp_effuid != SUPER_USER && diff --git a/servers/pm/mproc.h b/servers/pm/mproc.h index bb4cbf7bb..e6d07bbe6 100644 --- a/servers/pm/mproc.h +++ b/servers/pm/mproc.h @@ -84,5 +84,4 @@ EXTERN struct mproc { #define DELAY_CALL 0x20000 /* waiting for call before sending signal */ #define PM_SCHEDULED 0x40000 /* this process is scheduled by PM */ -#define NIL_MPROC ((struct mproc *) 0) diff --git a/servers/pm/trace.c b/servers/pm/trace.c index fd1b91139..7a466ec1d 100644 --- a/servers/pm/trace.c +++ b/servers/pm/trace.c @@ -58,7 +58,7 @@ PUBLIC int do_trace() return(OK); case T_ATTACH: /* attach to an existing process */ - if ((child = find_proc(m_in.pid)) == NIL_MPROC) return(ESRCH); + if ((child = find_proc(m_in.pid)) == NULL) return(ESRCH); if (child->mp_flags & EXITING) return(ESRCH); /* For non-root processes, user and group ID must match. */ @@ -98,7 +98,7 @@ PUBLIC int do_trace() case T_READB_INS: /* special hack for reading text segments */ if (mp->mp_effuid != SUPER_USER) return(EPERM); - if ((child = find_proc(m_in.pid)) == NIL_MPROC) return(ESRCH); + if ((child = find_proc(m_in.pid)) == NULL) return(ESRCH); if (child->mp_flags & EXITING) return(ESRCH); r = sys_trace(req, child->mp_endpoint, m_in.PMTRACE_ADDR, &m_in.data); @@ -109,7 +109,7 @@ PUBLIC int do_trace() case T_WRITEB_INS: /* special hack for patching text segments */ if (mp->mp_effuid != SUPER_USER) return(EPERM); - if ((child = find_proc(m_in.pid)) == NIL_MPROC) return(ESRCH); + if ((child = find_proc(m_in.pid)) == NULL) return(ESRCH); if (child->mp_flags & EXITING) return(ESRCH); #if 0 @@ -133,7 +133,7 @@ PUBLIC int do_trace() /* All the other calls are made by the tracing process to control execution * of the child. For all these calls, the child must be stopped. */ - if ((child = find_proc(m_in.pid)) == NIL_MPROC) return(ESRCH); + if ((child = find_proc(m_in.pid)) == NULL) return(ESRCH); if (child->mp_flags & EXITING) return(ESRCH); if (child->mp_tracer != who_p) return(ESRCH); if (!(child->mp_flags & STOPPED)) return(EBUSY); diff --git a/servers/pm/utility.c b/servers/pm/utility.c index 66ee1fac0..33e489e29 100644 --- a/servers/pm/utility.c +++ b/servers/pm/utility.c @@ -99,7 +99,7 @@ pid_t lpid; if ((rmp->mp_flags & IN_USE) && rmp->mp_pid == lpid) return(rmp); - return(NIL_MPROC); + return(NULL); } /*===========================================================================* diff --git a/servers/rs/const.h b/servers/rs/const.h index cabac55cb..e021a3e8b 100644 --- a/servers/rs/const.h +++ b/servers/rs/const.h @@ -46,7 +46,6 @@ /* Magic process table addresses. */ #define BEG_RPROC_ADDR (&rproc[0]) #define END_RPROC_ADDR (&rproc[NR_SYS_PROCS]) -#define NIL_RPROC ((struct mproc *) 0) /* Constants for live update. */ #define RS_DEFAULT_PREPARE_MAXTIME 2*RS_DELTA_T /* default prepare max time */ diff --git a/servers/vfs/device.c b/servers/vfs/device.c index 655419cea..598e13e12 100644 --- a/servers/vfs/device.c +++ b/servers/vfs/device.c @@ -596,7 +596,7 @@ PUBLIC int do_ioctl() register struct vnode *vp; dev_t dev; - if ((f = get_filp(m_in.ls_fd)) == NIL_FILP) return(err_code); + if ((f = get_filp(m_in.ls_fd)) == NULL) return(err_code); vp = f->filp_vno; /* get vnode pointer */ if ((vp->v_mode & I_TYPE) != I_CHAR_SPECIAL && (vp->v_mode & I_TYPE) != I_BLOCK_SPECIAL) return(ENOTTY); @@ -804,11 +804,11 @@ PUBLIC int clone_opcl( vp = fp->fp_filp[m_in.fd]->filp_vno; put_vnode(vp); - if ((vp = get_free_vnode()) == NIL_VNODE) + if ((vp = get_free_vnode()) == NULL) vp = fp->fp_filp[m_in.fd]->filp_vno; vp->v_fs_e = res.fs_e; - vp->v_vmnt = NIL_VMNT; + vp->v_vmnt = NULL; vp->v_dev = NO_DEV; vp->v_fs_e = res.fs_e; vp->v_inode_nr = res.inode_nr; diff --git a/servers/vfs/exec.c b/servers/vfs/exec.c index 1739f1178..708d0bcb7 100644 --- a/servers/vfs/exec.c +++ b/servers/vfs/exec.c @@ -114,7 +114,7 @@ vir_bytes frame_len; progname[PROC_NAME_LEN-1] = '\0'; /* Open executable */ - if ((vp = eat_path(PATH_NOFLAGS)) == NIL_VNODE) return(err_code); + if ((vp = eat_path(PATH_NOFLAGS)) == NULL) return(err_code); if ((vp->v_mode & I_TYPE) != I_REGULAR) r = ENOEXEC; diff --git a/servers/vfs/file.h b/servers/vfs/file.h index fda94da93..8ac8d09ba 100644 --- a/servers/vfs/file.h +++ b/servers/vfs/file.h @@ -39,4 +39,3 @@ EXTERN struct filp { * keep state. */ -#define NIL_FILP (struct filp *) 0 /* indicates absence of a filp slot */ diff --git a/servers/vfs/filedes.c b/servers/vfs/filedes.c index 3a363069a..a6c677969 100644 --- a/servers/vfs/filedes.c +++ b/servers/vfs/filedes.c @@ -31,7 +31,7 @@ PUBLIC int get_fd(int start, mode_t bits, int *k, struct filp **fpt) /* Search the fproc fp_filp table for a free file descriptor. */ for (i = start; i < OPEN_MAX; i++) { - if (fp->fp_filp[i] == NIL_FILP && !FD_ISSET(i, &fp->fp_filp_inuse)) { + if (fp->fp_filp[i] == NULL && !FD_ISSET(i, &fp->fp_filp_inuse)) { /* A file descriptor has been located. */ *k = i; break; @@ -85,12 +85,12 @@ int fild; /* file descriptor */ /* See if 'fild' refers to a valid file descr. If so, return its filp ptr. */ err_code = EBADF; - if (fild < 0 || fild >= OPEN_MAX ) return(NIL_FILP); - if (rfp->fp_filp[fild] == NIL_FILP && FD_ISSET(fild, &rfp->fp_filp_inuse)) + if (fild < 0 || fild >= OPEN_MAX ) return(NULL); + if (rfp->fp_filp[fild] == NULL && FD_ISSET(fild, &rfp->fp_filp_inuse)) err_code = EIO; /* The filedes is not there, but is not closed either. */ - return(rfp->fp_filp[fild]); /* may also be NIL_FILP */ + return(rfp->fp_filp[fild]); /* may also be NULL */ } @@ -115,7 +115,7 @@ PUBLIC struct filp *find_filp(register struct vnode *vp, mode_t bits) } /* If control passes here, the filp wasn't there. Report that back. */ - return(NIL_FILP); + return(NULL); } /*===========================================================================* @@ -131,7 +131,7 @@ PUBLIC int invalidate(struct filp *fp) if(fproc[f].fp_pid == PID_FREE) continue; for(fd = 0; fd < OPEN_MAX; fd++) { if(fproc[f].fp_filp[fd] && fproc[f].fp_filp[fd] == fp) { - fproc[f].fp_filp[fd] = NIL_FILP; + fproc[f].fp_filp[fd] = NULL; n++; } } diff --git a/servers/vfs/link.c b/servers/vfs/link.c index 8d62183be..3b8a6171f 100644 --- a/servers/vfs/link.c +++ b/servers/vfs/link.c @@ -34,12 +34,12 @@ PUBLIC int do_link() /* See if 'name1' (file to be linked to) exists. */ if(fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code); - if ((vp = eat_path(PATH_NOFLAGS)) == NIL_VNODE) return(err_code); + if ((vp = eat_path(PATH_NOFLAGS)) == NULL) return(err_code); /* Does the final directory of 'name2' exist? */ if (fetch_name(m_in.name2, m_in.name2_length, M1) != OK) r = err_code; - else if ((vp_d = last_dir()) == NIL_VNODE) + else if ((vp_d = last_dir()) == NULL) r = err_code; if (r != OK) { put_vnode(vp); @@ -76,7 +76,7 @@ PUBLIC int do_unlink() /* Get the last directory in the path. */ if(fetch_name(m_in.name, m_in.name_length, M3) != OK) return(err_code); - if ((vldirp = last_dir()) == NIL_VNODE) return(err_code); + if ((vldirp = last_dir()) == NULL) return(err_code); /* Make sure that the object is a directory */ if((vldirp->v_mode & I_TYPE) != I_DIRECTORY) { @@ -95,7 +95,7 @@ PUBLIC int do_unlink() if ((vldirp->v_mode & S_ISVTX) == S_ISVTX) { /* Look up inode of file to unlink to retrieve owner */ vp = advance(vldirp, PATH_RET_SYMLINK); - if (vp != NIL_VNODE) { + if (vp != NULL) { if(vp->v_uid != fp->fp_effuid && fp->fp_effuid != SU_UID) r = EPERM; put_vnode(vp); @@ -129,14 +129,14 @@ PUBLIC int do_rename() /* See if 'name1' (existing file) exists. Get dir and file inodes. */ if(fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code); - if ((old_dirp = last_dir()) == NIL_VNODE) return(err_code); + if ((old_dirp = last_dir()) == NULL) return(err_code); /* If the sticky bit is set, only the owner of the file or a privileged user is allowed to rename */ if((old_dirp->v_mode & S_ISVTX) == S_ISVTX) { /* Look up inode of file to unlink to retrieve owner */ vp = advance(old_dirp, PATH_RET_SYMLINK); - if (vp != NIL_VNODE) { + if (vp != NULL) { if(vp->v_uid != fp->fp_effuid && fp->fp_effuid != SU_UID) r = EPERM; put_vnode(vp); @@ -158,7 +158,7 @@ PUBLIC int do_rename() /* See if 'name2' (new name) exists. Get dir inode */ if(fetch_name(m_in.name2, m_in.name2_length, M1) != OK) r = err_code; - else if ((new_dirp = last_dir()) == NIL_VNODE) + else if ((new_dirp = last_dir()) == NULL) r = err_code; if (r != OK) { put_vnode(old_dirp); @@ -198,7 +198,7 @@ PUBLIC int do_truncate() /* Temporarily open file */ if (fetch_name(m_in.m2_p1, m_in.m2_i1, M1) != OK) return(err_code); - if ((vp = eat_path(PATH_NOFLAGS)) == NIL_VNODE) return(err_code); + if ((vp = eat_path(PATH_NOFLAGS)) == NULL) return(err_code); /* Ask FS to truncate the file */ if ((r = forbidden(vp, W_BIT)) == OK) @@ -220,7 +220,7 @@ PUBLIC int do_ftruncate() if ((off_t) m_in.flength < 0) return(EINVAL); /* File is already opened; get a vnode pointer from filp */ - if ((rfilp = get_filp(m_in.m2_i1)) == NIL_FILP) return(err_code); + if ((rfilp = get_filp(m_in.m2_i1)) == NULL) return(err_code); if (!(rfilp->filp_mode & W_BIT)) return(EBADF); return truncate_vnode(rfilp->filp_vno, m_in.flength); } @@ -259,7 +259,7 @@ PUBLIC int do_slink() /* Get dir inode of 'name2' */ if(fetch_name(m_in.name2, m_in.name2_length, M1) != OK) return(err_code); - if ((vp = last_dir()) == NIL_VNODE) return(err_code); + if ((vp = last_dir()) == NULL) return(err_code); if ((r = forbidden(vp, W_BIT|X_BIT)) == OK) { r = req_slink(vp->v_fs_e, vp->v_inode_nr, user_fullpath, who_e, @@ -286,7 +286,7 @@ PUBLIC int do_rdlink() /* Temporarily open the file containing the symbolic link */ if(fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code); - if ((vp = eat_path(PATH_RET_SYMLINK)) == NIL_VNODE) return(err_code); + if ((vp = eat_path(PATH_RET_SYMLINK)) == NULL) return(err_code); /* Make sure this is a symbolic link */ if((vp->v_mode & I_TYPE) != I_SYMBOLIC_LINK) diff --git a/servers/vfs/lock.c b/servers/vfs/lock.c index 0c0f6f98a..25e42b6ba 100644 --- a/servers/vfs/lock.c +++ b/servers/vfs/lock.c @@ -70,10 +70,10 @@ int req; /* either F_SETLK or F_SETLKW */ if (last < first) return(EINVAL); /* Check if this region conflicts with any existing lock. */ - empty = NIL_LOCK; + empty = NULL; for (flp = &file_lock[0]; flp < &file_lock[NR_LOCKS]; flp++) { if (flp->lock_type == 0) { - if (empty == NIL_LOCK) empty = flp; + if (empty == NULL) empty = flp; continue; /* 0 means unused slot */ } if (flp->lock_vnode != f->filp_vno) continue; /* different file */ @@ -155,7 +155,7 @@ int req; /* either F_SETLK or F_SETLKW */ if (ltype == F_UNLCK) return(OK); /* unlocked a region with no locks */ /* There is no conflict. If space exists, store new lock in the table. */ - if (empty == NIL_LOCK) return(ENOLCK); /* table full */ + if (empty == NULL) return(ENOLCK); /* table full */ empty->lock_type = ltype; empty->lock_pid = fp->fp_pid; empty->lock_vnode = f->filp_vno; diff --git a/servers/vfs/lock.h b/servers/vfs/lock.h index 40500033c..95ab56c83 100644 --- a/servers/vfs/lock.h +++ b/servers/vfs/lock.h @@ -9,5 +9,4 @@ EXTERN struct file_lock { off_t lock_last; /* offset of last byte locked */ } file_lock[NR_LOCKS]; -#define NIL_LOCK (struct file_lock *) 0 diff --git a/servers/vfs/main.c b/servers/vfs/main.c index 5b5f915d4..d2a62d436 100644 --- a/servers/vfs/main.c +++ b/servers/vfs/main.c @@ -472,7 +472,7 @@ PRIVATE void init_root() vmp = &vmnt[0]; /* We'll need a vnode for the root inode, check whether there is one */ - if ((root_node = get_free_vnode()) == NIL_VNODE) + if ((root_node = get_free_vnode()) == NULL) panic("Cannot get free vnode: %d", r); diff --git a/servers/vfs/misc.c b/servers/vfs/misc.c index 6d3c25fab..8cd9e7e30 100644 --- a/servers/vfs/misc.c +++ b/servers/vfs/misc.c @@ -120,7 +120,7 @@ PUBLIC int do_dup() /* Is the file descriptor valid? */ rfd = m_in.fd & ~DUP_MASK; /* kill off dup2 bit, if on */ - if ((f = get_filp(rfd)) == NIL_FILP) return(err_code); + if ((f = get_filp(rfd)) == NULL) return(err_code); /* Distinguish between dup and dup2. */ if (m_in.fd == rfd) { /* bit not on */ @@ -154,7 +154,7 @@ PUBLIC int do_fcntl() struct filp *dummy; /* Is the file descriptor valid? */ - if ((f = get_filp(m_in.fd)) == NIL_FILP) return(err_code); + if ((f = get_filp(m_in.fd)) == NULL) return(err_code); switch (m_in.request) { case F_DUPFD: @@ -374,7 +374,7 @@ int cpid; /* Child process id */ fp = &fproc[parentno]; for (i = 0; i < OPEN_MAX; i++) - if (cp->fp_filp[i] != NIL_FILP) cp->fp_filp[i]->filp_count++; + if (cp->fp_filp[i] != NULL) cp->fp_filp[i]->filp_count++; /* Fill in new process and endpoint id. */ cp->fp_pid = cpid; @@ -443,8 +443,8 @@ PRIVATE void free_proc(struct fproc *exiter, int flags) unsuspend_by_endpt(fp->fp_endpoint); /* Release root and working directories. */ - if(fp->fp_rd) { put_vnode(fp->fp_rd); fp->fp_rd = NIL_VNODE; } - if(fp->fp_wd) { put_vnode(fp->fp_wd); fp->fp_wd = NIL_VNODE; } + if(fp->fp_rd) { put_vnode(fp->fp_rd); fp->fp_rd = NULL; } + if(fp->fp_wd) { put_vnode(fp->fp_wd); fp->fp_wd = NULL; } /* The rest of these actions is only done when processes actually * exit. @@ -469,7 +469,7 @@ PRIVATE void free_proc(struct fproc *exiter, int flags) if (rfp->fp_tty == dev) rfp->fp_tty = 0; for (i = 0; i < OPEN_MAX; i++) { - if ((rfilp = rfp->fp_filp[i]) == NIL_FILP) continue; + if ((rfilp = rfp->fp_filp[i]) == NULL) continue; if (rfilp->filp_mode == FILP_CLOSED) continue; vp = rfilp->filp_vno; if ((vp->v_mode & I_TYPE) != I_CHAR_SPECIAL) continue; diff --git a/servers/vfs/mount.c b/servers/vfs/mount.c index b2089acdf..7da620c7a 100644 --- a/servers/vfs/mount.c +++ b/servers/vfs/mount.c @@ -190,7 +190,7 @@ PRIVATE int mount_fs(endpoint_t fs_e) /* Scan vmnt table to see if dev already mounted. If not, find a free slot.*/ found = FALSE; - vmp = NIL_VMNT; + vmp = NULL; for (i = 0; i < NR_MNTS; ++i) { if (vmnt[i].m_dev == dev) { vmp = &vmnt[i]; @@ -213,7 +213,7 @@ PRIVATE int mount_fs(endpoint_t fs_e) /* Now get the inode of the file to be mounted on. */ if (fetch_name(m_in.name2, m_in.name2_length, M1)!=OK) return(err_code); - if ((vp = eat_path(PATH_NOFLAGS)) == NIL_VNODE) return(err_code); + if ((vp = eat_path(PATH_NOFLAGS)) == NULL) return(err_code); if (vp->v_ref_count != 1) { put_vnode(vp); return(EBUSY); @@ -251,7 +251,7 @@ PRIVATE int mount_fs(endpoint_t fs_e) if(!replace_root) { /* Get vnode of mountpoint */ - if ((vp = eat_path(PATH_NOFLAGS)) == NIL_VNODE) return(err_code); + if ((vp = eat_path(PATH_NOFLAGS)) == NULL) return(err_code); /* Tell FS on which vnode it is mounted (glue into mount tree) */ if ((r = req_mountpoint(vp->v_fs_e, vp->v_inode_nr)) != OK) { @@ -261,8 +261,8 @@ PRIVATE int mount_fs(endpoint_t fs_e) } /* We'll need a vnode for the root inode, check whether there is one */ - if ((root_node = get_free_vnode()) == NIL_VNODE) { - if (vp != NIL_VNODE) put_vnode(vp); + if ((root_node = get_free_vnode()) == NULL) { + if (vp != NULL) put_vnode(vp); return(ENFILE); } @@ -272,7 +272,7 @@ PRIVATE int mount_fs(endpoint_t fs_e) dp = &dmap[(dev >> MAJOR) & BYTE]; if (dp->dmap_driver == NONE) { printf("VFS: no driver for dev %x\n", dev); - if (vp != NIL_VNODE) put_vnode(vp); + if (vp != NULL) put_vnode(vp); return(EINVAL); } @@ -283,7 +283,7 @@ PRIVATE int mount_fs(endpoint_t fs_e) /* Tell FS which device to mount */ if ((r = req_readsuper(fs_e, label, dev, rdonly, isroot, &res)) != OK) { - if (vp != NIL_VNODE) put_vnode(vp); + if (vp != NULL) put_vnode(vp); return(r); } @@ -434,7 +434,7 @@ PUBLIC int unmount( if (vmp->m_mounted_on) { put_vnode(vmp->m_mounted_on); - vmp->m_mounted_on = NIL_VNODE; + vmp->m_mounted_on = NULL; } /* Tell FS to unmount */ @@ -453,7 +453,7 @@ PUBLIC int unmount( vmp->m_root_node->v_ref_count = 0; vmp->m_root_node->v_fs_count = 0; vmp->m_root_node->v_sdev = NO_DEV; - vmp->m_root_node = NIL_VNODE; + vmp->m_root_node = NULL; vmp->m_dev = NO_DEV; vmp->m_fs_e = NONE; @@ -498,7 +498,7 @@ PRIVATE dev_t name_to_dev(int allow_mountpt) struct vnode *vp; /* Request lookup */ - if ((vp = eat_path(PATH_NOFLAGS)) == NIL_VNODE) { + if ((vp = eat_path(PATH_NOFLAGS)) == NULL) { return(NO_DEV); } diff --git a/servers/vfs/open.c b/servers/vfs/open.c index 9282e00a6..5a9c9805e 100644 --- a/servers/vfs/open.c +++ b/servers/vfs/open.c @@ -104,7 +104,7 @@ PRIVATE int common_open(register int oflags, mode_t omode) flag is set this is an error */ } else { /* Scan path name */ - if ((vp = eat_path(PATH_NOFLAGS)) == NIL_VNODE) return(err_code); + if ((vp = eat_path(PATH_NOFLAGS)) == NULL) return(err_code); } /* Claim the file descriptor and filp slot and fill them in. */ @@ -194,7 +194,7 @@ PRIVATE int common_open(register int oflags, mode_t omode) */ b = (bits & R_BIT ? R_BIT : W_BIT); fil_ptr->filp_count = 0; /* don't find self */ - if ((filp2 = find_filp(vp, b)) != NIL_FILP) { + if ((filp2 = find_filp(vp, b)) != NULL) { /* Co-reader or writer found. Use it.*/ fp->fp_filp[m_in.fd] = filp2; filp2->filp_count++; @@ -222,11 +222,11 @@ PRIVATE int common_open(register int oflags, mode_t omode) /* If error, release inode. */ if (r != OK) { if (r == SUSPEND) return(r); /* Oops, just suspended */ - fp->fp_filp[m_in.fd] = NIL_FILP; + fp->fp_filp[m_in.fd] = NULL; FD_CLR(m_in.fd, &fp->fp_filp_inuse); fil_ptr->filp_count= 0; put_vnode(vp); - fil_ptr->filp_vno = NIL_VNODE; + fil_ptr->filp_vno = NULL; return(r); } @@ -241,7 +241,7 @@ PRIVATE struct vnode *new_node(int oflags, mode_t bits) { /* Try to create a new inode and return a pointer to it. If the inode already exists, return a pointer to it as well, but set err_code accordingly. - NIL_VNODE is returned if the path cannot be resolved up to the last + NULL is returned if the path cannot be resolved up to the last directory, or when the inode cannot be created due to permissions or otherwise. */ struct vnode *dirp, *vp; @@ -254,7 +254,7 @@ PRIVATE struct vnode *new_node(int oflags, mode_t bits) if (oflags & O_EXCL) flags |= PATH_RET_SYMLINK; /* See if the path can be opened down to the last directory. */ - if ((dirp = last_dir()) == NIL_VNODE) return(NIL_VNODE); + if ((dirp = last_dir()) == NULL) return(NULL); /* The final directory is accessible. Get final component of the path. */ vp = advance(dirp, flags); @@ -263,12 +263,12 @@ PRIVATE struct vnode *new_node(int oflags, mode_t bits) * symlink results in a new path that needs to be re-resolved entirely. */ if (user_fullpath[0] == '/') return new_node(oflags, bits); - if (vp == NIL_VNODE && err_code == ENOENT) { + if (vp == NULL && err_code == ENOENT) { /* Last path component does not exist. Make a new directory entry. */ - if ((vp = get_free_vnode()) == NIL_VNODE) { + if ((vp = get_free_vnode()) == NULL) { /* Can't create new vnode: out of vnodes. */ put_vnode(dirp); - return(NIL_VNODE); + return(NULL); } if ((r = forbidden(dirp, W_BIT|X_BIT)) != OK || (r = req_create(dirp->v_fs_e, dirp->v_inode_nr,bits, fp->fp_effuid, @@ -281,7 +281,7 @@ PRIVATE struct vnode *new_node(int oflags, mode_t bits) /* Resolve path up to symlink */ slp = advance(dirp, PATH_RET_SYMLINK); - if (slp != NIL_VNODE) { + if (slp != NULL) { if (S_ISLNK(slp->v_mode)) { /* Get contents of link */ @@ -297,7 +297,7 @@ PRIVATE struct vnode *new_node(int oflags, mode_t bits) put_vnode(slp); put_vnode(dirp); err_code = r; - return(NIL_VNODE); + return(NULL); } user_fullpath[r] = '\0';/* Term. path*/ } @@ -313,7 +313,7 @@ PRIVATE struct vnode *new_node(int oflags, mode_t bits) vp = new_node(oflags, bits); fp->fp_wd = old_wd; /* Restore */ - if (vp != NIL_VNODE) { + if (vp != NULL) { put_vnode(dirp); return(vp); } @@ -328,7 +328,7 @@ PRIVATE struct vnode *new_node(int oflags, mode_t bits) err_code = r; put_vnode(dirp); - return(NIL_VNODE); + return(NULL); } /* Store results and mark vnode in use */ @@ -345,7 +345,7 @@ PRIVATE struct vnode *new_node(int oflags, mode_t bits) vp->v_ref_count = 1; } else { /* Either last component exists, or there is some other problem. */ - if (vp != NIL_VNODE) + if (vp != NULL) r = EEXIST; /* File exists or a symlink names a file while * O_EXCL is set. */ else @@ -374,7 +374,7 @@ PRIVATE int pipe_open(register struct vnode *vp, register mode_t bits, if((bits & (R_BIT|W_BIT)) == (R_BIT|W_BIT)) return(ENXIO); - if (find_filp(vp, bits & W_BIT ? R_BIT : W_BIT) == NIL_FILP) { + if (find_filp(vp, bits & W_BIT ? R_BIT : W_BIT) == NULL) { if (oflags & O_NONBLOCK) { if (bits & W_BIT) return(ENXIO); } else { @@ -406,7 +406,7 @@ PUBLIC int do_mknod() /* Open directory that's going to hold the new node. */ if(fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code); - if((vp = last_dir()) == NIL_VNODE) return(err_code); + if((vp = last_dir()) == NULL) return(err_code); /* Make sure that the object is a directory */ if((vp->v_mode & I_TYPE) != I_DIRECTORY) { @@ -439,7 +439,7 @@ PUBLIC int do_mkdir() bits = I_DIRECTORY | (m_in.mode & RWX_MODES & fp->fp_umask); /* Request lookup */ - if((vp = last_dir()) == NIL_VNODE) return(err_code); + if((vp = last_dir()) == NULL) return(err_code); /* Make sure that the object is a directory */ if ((vp->v_mode & I_TYPE) != I_DIRECTORY) { @@ -469,7 +469,7 @@ PUBLIC int do_lseek() u64_t pos, newpos; /* Check to see if the file descriptor is valid. */ - if ( (rfilp = get_filp(m_in.ls_fd)) == NIL_FILP) return(err_code); + if ( (rfilp = get_filp(m_in.ls_fd)) == NULL) return(err_code); /* No lseek on pipes. */ if (rfilp->filp_vno->v_pipe == I_PIPE) return(ESPIPE); @@ -517,7 +517,7 @@ PUBLIC int do_llseek() int r; /* Check to see if the file descriptor is valid. */ - if ( (rfilp = get_filp(m_in.ls_fd)) == NIL_FILP) return(err_code); + if ( (rfilp = get_filp(m_in.ls_fd)) == NULL) return(err_code); /* No lseek on pipes. */ if (rfilp->filp_vno->v_pipe == I_PIPE) return(ESPIPE); @@ -574,12 +574,12 @@ int fd_nr; int lock_count; /* First locate the vnode that belongs to the file descriptor. */ - if ( (rfilp = get_filp2(rfp, fd_nr)) == NIL_FILP) return(err_code); + if ( (rfilp = get_filp2(rfp, fd_nr)) == NULL) return(err_code); vp = rfilp->filp_vno; close_filp(rfilp); FD_CLR(fd_nr, &rfp->fp_cloexec_set); - rfp->fp_filp[fd_nr] = NIL_FILP; + rfp->fp_filp[fd_nr] = NULL; FD_CLR(fd_nr, &rfp->fp_filp_inuse); /* Check to see if the file is locked. If so, release all locks. */ diff --git a/servers/vfs/path.c b/servers/vfs/path.c index da89b86ac..c85af71f7 100644 --- a/servers/vfs/path.c +++ b/servers/vfs/path.c @@ -47,16 +47,16 @@ int flags; assert(dirp); /* Get a free vnode */ - if((new_vp = get_free_vnode()) == NIL_VNODE) return(NIL_VNODE); + if((new_vp = get_free_vnode()) == NULL) return(NULL); /* Lookup vnode belonging to the file. */ if ((r = lookup(dirp, flags, &res)) != OK) { err_code = r; - return(NIL_VNODE); + return(NULL); } /* Check whether vnode is already in use or not */ - if ((vp = find_vnode(res.fs_e, res.inode_nr)) != NIL_VNODE) { + if ((vp = find_vnode(res.fs_e, res.inode_nr)) != NULL) { dup_vnode(vp); vp->v_fs_count++; /* We got a reference from the FS */ return(vp); @@ -71,7 +71,7 @@ int flags; new_vp->v_gid = res.gid; new_vp->v_sdev = res.dev; - if( (vmp = find_vmnt(new_vp->v_fs_e)) == NIL_VMNT) + if( (vmp = find_vmnt(new_vp->v_fs_e)) == NULL) panic("VFS advance: vmnt not found"); new_vp->v_vmnt = vmp; @@ -105,7 +105,7 @@ PUBLIC struct vnode *last_dir(void) /* Parse a path, 'user_fullpath', as far as the last directory, fetch the vnode * for the last directory into the vnode table, and return a pointer to the * vnode. In addition, return the final component of the path in 'string'. If - * the last directory can't be opened, return NIL_VNODE and the reason for + * the last directory can't be opened, return NULL and the reason for * failure in 'err_code'. We can't parse component by component as that would * be too expensive. Alternatively, we cut off the last component of the path, * and parse the path up to the penultimate component. @@ -124,7 +124,7 @@ PUBLIC struct vnode *last_dir(void) /* If path is empty, return ENOENT. */ if (len == 0) { err_code = ENOENT; - return(NIL_VNODE); + return(NULL); } #if !DO_POSIX_PATHNAME_RES @@ -156,7 +156,7 @@ PUBLIC struct vnode *last_dir(void) } res = advance(vp, PATH_NOFLAGS); - if (res == NIL_VNODE) return(NIL_VNODE); + if (res == NULL) return(NULL); /* Copy the directory entry back to user_fullpath */ strcpy(user_fullpath, dir_entry); @@ -253,7 +253,7 @@ node_details_t *node; /* Climbing up mount */ /* Find the vmnt that represents the partition on * which we "climb up". */ - if ((vmp = find_vmnt(res.fs_e)) == NIL_VMNT) { + if ((vmp = find_vmnt(res.fs_e)) == NULL) { panic("VFS lookup: can't find parent vmnt"); } diff --git a/servers/vfs/pipe.c b/servers/vfs/pipe.c index 15cfdefe1..414992775 100644 --- a/servers/vfs/pipe.c +++ b/servers/vfs/pipe.c @@ -49,7 +49,7 @@ PUBLIC int do_pipe() struct node_details res; /* See if a free vnode is available */ - if ( (vp = get_free_vnode()) == NIL_VNODE) return(err_code); + if ( (vp = get_free_vnode()) == NULL) return(err_code); /* Acquire two file descriptors. */ rfp = fp; @@ -58,7 +58,7 @@ PUBLIC int do_pipe() FD_SET(fil_des[0], &rfp->fp_filp_inuse); fil_ptr0->filp_count = 1; if ((r = get_fd(0, W_BIT, &fil_des[1], &fil_ptr1)) != OK) { - rfp->fp_filp[fil_des[0]] = NIL_FILP; + rfp->fp_filp[fil_des[0]] = NULL; FD_CLR(fil_des[0], &rfp->fp_filp_inuse); fil_ptr0->filp_count = 0; return(r); @@ -72,10 +72,10 @@ PUBLIC int do_pipe() NO_DEV, &res); if (r != OK) { - rfp->fp_filp[fil_des[0]] = NIL_FILP; + rfp->fp_filp[fil_des[0]] = NULL; FD_CLR(fil_des[0], &rfp->fp_filp_inuse); fil_ptr0->filp_count = 0; - rfp->fp_filp[fil_des[1]] = NIL_FILP; + rfp->fp_filp[fil_des[1]] = NULL; FD_CLR(fil_des[1], &rfp->fp_filp_inuse); fil_ptr1->filp_count = 0; return(r); @@ -94,7 +94,7 @@ PUBLIC int do_pipe() vp->v_mapfs_count = 1; vp->v_ref_count = 1; vp->v_size = 0; - vp->v_vmnt = NIL_VMNT; + vp->v_vmnt = NULL; vp->v_dev = NO_DEV; /* Fill in filp objects */ @@ -163,7 +163,7 @@ int notouch; /* check only */ if (rw_flag == READING) { if (pos >= vp->v_size) { /* Process is reading from an empty pipe. */ - if (find_filp(vp, W_BIT) != NIL_FILP) { + if (find_filp(vp, W_BIT) != NULL) { /* Writer exists */ if (oflags & O_NONBLOCK) r = EAGAIN; @@ -180,7 +180,7 @@ int notouch; /* check only */ } /* Process is writing to a pipe. */ - if (find_filp(vp, R_BIT) == NIL_FILP) { + if (find_filp(vp, R_BIT) == NULL) { /* Process is writing, but there is no reader. Tell kernel to generate * a SIGPIPE signal. */ if (!notouch) sys_kill(fp->fp_endpoint, SIGPIPE); @@ -430,7 +430,7 @@ int returned; /* if hanging on task, how many bytes read */ fd_nr = rfp->fp_fd>>8; if (returned < 0) { fil_ptr = rfp->fp_filp[fd_nr]; - rfp->fp_filp[fd_nr] = NIL_FILP; + rfp->fp_filp[fd_nr] = NULL; FD_CLR(fd_nr, &rfp->fp_filp_inuse); if (fil_ptr->filp_count != 1) { panic("revive: bad count in filp: %d", @@ -438,7 +438,7 @@ int returned; /* if hanging on task, how many bytes read */ } fil_ptr->filp_count = 0; put_vnode(fil_ptr->filp_vno); - fil_ptr->filp_vno = NIL_VNODE; + fil_ptr->filp_vno = NULL; reply(proc_nr_e, returned); } else reply(proc_nr_e, fd_nr); diff --git a/servers/vfs/protect.c b/servers/vfs/protect.c index 10fa125e7..e9ca0bd64 100644 --- a/servers/vfs/protect.c +++ b/servers/vfs/protect.c @@ -35,7 +35,7 @@ PUBLIC int do_chmod() if (call_nr == CHMOD) { /* Temporarily open the file */ if(fetch_name(m_in.name, m_in.name_length, M3) != OK) return(err_code); - if ((vp = eat_path(PATH_NOFLAGS)) == NIL_VNODE) return(err_code); + if ((vp = eat_path(PATH_NOFLAGS)) == NULL) return(err_code); } else { /* call_nr == FCHMOD */ /* File is already opened; get a pointer to vnode from filp. */ if (!(flp = get_filp(m_in.fd))) return(err_code); @@ -85,7 +85,7 @@ PUBLIC int do_chown() if (call_nr == CHOWN) { /* Temporarily open the file. */ if(fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code); - if ((vp = eat_path(PATH_NOFLAGS)) == NIL_VNODE) return(err_code); + if ((vp = eat_path(PATH_NOFLAGS)) == NULL) return(err_code); } else { /* call_nr == FCHOWN */ /* File is already opened; get a pointer to the vnode from filp. */ if (!(flp = get_filp(m_in.fd))) return(err_code); @@ -152,7 +152,7 @@ PUBLIC int do_access() /* Temporarily open the file. */ if (fetch_name(m_in.name, m_in.name_length, M3) != OK) return(err_code); - if ((vp = eat_path(PATH_NOFLAGS)) == NIL_VNODE) return(err_code); + if ((vp = eat_path(PATH_NOFLAGS)) == NULL) return(err_code); r = forbidden(vp, m_in.mode); put_vnode(vp); diff --git a/servers/vfs/read.c b/servers/vfs/read.c index a1a377c8e..9b6853ac3 100644 --- a/servers/vfs/read.c +++ b/servers/vfs/read.c @@ -51,7 +51,7 @@ int rw_flag; /* READING or WRITING */ /* If the file descriptor is valid, get the vnode, size and mode. */ if (m_in.nbytes < 0) return(EINVAL); - if ((f = get_filp(m_in.fd)) == NIL_FILP) return(err_code); + if ((f = get_filp(m_in.fd)) == NULL) return(err_code); if (((f->filp_mode) & (rw_flag == READING ? R_BIT : W_BIT)) == 0) { return(f->filp_mode == FILP_CLOSED ? EIO : EBADF); } @@ -154,7 +154,7 @@ PUBLIC int do_getdents() register struct filp *rfilp; /* Is the file descriptor valid? */ - if ( (rfilp = get_filp(m_in.fd)) == NIL_FILP) { + if ( (rfilp = get_filp(m_in.fd)) == NULL) { return(err_code); } diff --git a/servers/vfs/select.c b/servers/vfs/select.c index 46880cdf7..3dcf25497 100644 --- a/servers/vfs/select.c +++ b/servers/vfs/select.c @@ -146,7 +146,7 @@ PUBLIC int do_select(void) /* Get filp belonging to this fd */ filp = se->filps[fd] = get_filp(fd); - if (filp == NIL_FILP) { + if (filp == NULL) { if (err_code == EBADF) { select_cancel_all(se); return(EBADF); @@ -695,8 +695,8 @@ PUBLIC void select_unsuspend_by_endpt(endpoint_t proc_e) if (selecttab[s].requestor == NULL) continue; for(fd = 0; fd < selecttab[s].nfds; fd++) { - if (selecttab[s].filps[fd] == NIL_FILP || - selecttab[s].filps[fd]->filp_vno == NIL_VNODE) { + if (selecttab[s].filps[fd] == NULL || + selecttab[s].filps[fd]->filp_vno == NULL) { continue; } diff --git a/servers/vfs/stadir.c b/servers/vfs/stadir.c index 30a0d6ce9..142784f25 100644 --- a/servers/vfs/stadir.c +++ b/servers/vfs/stadir.c @@ -36,7 +36,7 @@ PUBLIC int do_fchdir() struct filp *rfilp; /* Is the file descriptor valid? */ - if ((rfilp = get_filp(m_in.fd)) == NIL_FILP) return(err_code); + if ((rfilp = get_filp(m_in.fd)) == NULL) return(err_code); dup_vnode(rfilp->filp_vno); /* Change into expects a reference. */ return change_into(&fp->fp_wd, rfilp->filp_vno); } @@ -78,7 +78,7 @@ int len; /* length of the directory name string */ /* Try to open the directory */ if (fetch_name(name_ptr, len, M3) != OK) return(err_code); - if ((vp = eat_path(PATH_NOFLAGS)) == NIL_VNODE) return(err_code); + if ((vp = eat_path(PATH_NOFLAGS)) == NULL) return(err_code); return change_into(iip, vp); } @@ -121,7 +121,7 @@ PUBLIC int do_stat() struct vnode *vp; if (fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code); - if ((vp = eat_path(PATH_NOFLAGS)) == NIL_VNODE) return(err_code); + if ((vp = eat_path(PATH_NOFLAGS)) == NULL) return(err_code); r = req_stat(vp->v_fs_e, vp->v_inode_nr, who_e, m_in.name2, 0); put_vnode(vp); @@ -139,7 +139,7 @@ PUBLIC int do_fstat() int pipe_pos = 0; /* Is the file descriptor valid? */ - if ((rfilp = get_filp(m_in.fd)) == NIL_FILP) return(err_code); + if ((rfilp = get_filp(m_in.fd)) == NULL) return(err_code); /* If we read from a pipe, send position too */ if (rfilp->filp_vno->v_pipe == I_PIPE) { @@ -164,7 +164,7 @@ PUBLIC int do_fstatfs() struct filp *rfilp; /* Is the file descriptor valid? */ - if( (rfilp = get_filp(m_in.fd)) == NIL_FILP) return(err_code); + if( (rfilp = get_filp(m_in.fd)) == NULL) return(err_code); return req_fstatfs(rfilp->filp_vno->v_fs_e, who_e, m_in.buffer); } @@ -180,7 +180,7 @@ PUBLIC int do_lstat() int r; if (fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code); - if ((vp = eat_path(PATH_RET_SYMLINK)) == NIL_VNODE) return(err_code); + if ((vp = eat_path(PATH_RET_SYMLINK)) == NULL) return(err_code); r = req_stat(vp->v_fs_e, vp->v_inode_nr, who_e, m_in.name2, 0); put_vnode(vp); diff --git a/servers/vfs/time.c b/servers/vfs/time.c index 7ee63e57b..cf279ddac 100644 --- a/servers/vfs/time.c +++ b/servers/vfs/time.c @@ -32,7 +32,7 @@ PUBLIC int do_utime() /* Temporarily open the file */ if (fetch_name(m_in.utime_file, len, M1) != OK) return(err_code); - if ((vp = eat_path(PATH_NOFLAGS)) == NIL_VNODE) return(err_code); + if ((vp = eat_path(PATH_NOFLAGS)) == NULL) return(err_code); /* Only the owner of a file or the super user can change its name. */ r = OK; diff --git a/servers/vfs/vmnt.c b/servers/vfs/vmnt.c index 03cee6f7b..842abc1cc 100644 --- a/servers/vfs/vmnt.c +++ b/servers/vfs/vmnt.c @@ -16,7 +16,7 @@ PUBLIC struct vmnt *get_free_vmnt(short *index) for (vp = &vmnt[0]; vp < &vmnt[NR_MNTS]; ++vp, ++(*index)) if (vp->m_dev == NO_DEV) return(vp); - return(NIL_VMNT); + return(NULL); } @@ -29,7 +29,7 @@ PUBLIC struct vmnt *find_vmnt(int fs_e) for (vp = &vmnt[0]; vp < &vmnt[NR_MNTS]; ++vp) if (vp->m_fs_e == fs_e) return(vp); - return(NIL_VMNT); + return(NULL); } diff --git a/servers/vfs/vmnt.h b/servers/vfs/vmnt.h index 199f67efc..390d93e67 100644 --- a/servers/vfs/vmnt.h +++ b/servers/vfs/vmnt.h @@ -9,4 +9,3 @@ EXTERN struct vmnt { char m_label[LABEL_MAX]; /* label of the file system process */ } vmnt[NR_MNTS]; -#define NIL_VMNT (struct vmnt *) 0 diff --git a/servers/vfs/vnode.c b/servers/vfs/vnode.c index 04b6a2869..3b07ef68a 100644 --- a/servers/vfs/vnode.c +++ b/servers/vfs/vnode.c @@ -51,7 +51,7 @@ PUBLIC struct vnode *get_free_vnode() } err_code = ENFILE; - return(NIL_VNODE); + return(NULL); } @@ -68,7 +68,7 @@ PUBLIC struct vnode *find_vnode(int fs_e, int numb) if (vp->v_ref_count > 0 && vp->v_inode_nr == numb && vp->v_fs_e == fs_e) return(vp); - return(NIL_VNODE); + return(NULL); } @@ -147,7 +147,7 @@ PUBLIC void vnode_clean_refs(struct vnode *vp) { /* Tell the underlying FS to drop all reference but one. */ - if (vp == NIL_VNODE) return; + if (vp == NULL) return; if (vp->v_fs_count <= 1) return; /* Nothing to do */ /* Drop all references except one */ diff --git a/servers/vfs/vnode.h b/servers/vfs/vnode.h index 110d231b0..9ce588d7e 100644 --- a/servers/vfs/vnode.h +++ b/servers/vfs/vnode.h @@ -26,7 +26,6 @@ EXTERN struct vnode { struct vmnt *v_vmnt; /* vmnt object of the partition */ } vnode[NR_VNODES]; -#define NIL_VNODE (struct vnode *) 0 /* indicates absence of vnode slot */ /* Field values. */ #define NO_PIPE 0 /* i_pipe is NO_PIPE if inode is not a pipe */ diff --git a/servers/vm/alloc.c b/servers/vm/alloc.c index 30eed4aed..f846b7467 100644 --- a/servers/vm/alloc.c +++ b/servers/vm/alloc.c @@ -62,7 +62,6 @@ struct hole { static int startpages; -#define NIL_HOLE (struct hole *) 0 #define _NR_HOLES (_NR_PROCS*2) /* No. of memory holes maintained by VM */ @@ -190,9 +189,9 @@ PUBLIC phys_clicks alloc_mem(phys_clicks clicks, u32_t memflags) } } else { CHECKHOLES; - prev_ptr = NIL_HOLE; + prev_ptr = NULL; hp = hole_head; - while (hp != NIL_HOLE) { + while (hp != NULL) { if (hp->h_len >= clicks) { /* We found a hole that is big enough. Use it. */ old_base = hp->h_base; /* remember where it started */ @@ -262,7 +261,7 @@ CHECKHOLES; return; } - if ( (new_ptr = free_slots) == NIL_HOLE) + if ( (new_ptr = free_slots) == NULL) panic("hole table full"); new_ptr->h_base = base; new_ptr->h_len = clicks; @@ -273,7 +272,7 @@ CHECKHOLES; * available, or if no holes are currently available, put this hole on the * front of the hole list. */ - if (hp == NIL_HOLE || base <= hp->h_base) { + if (hp == NULL || base <= hp->h_base) { /* Block to be freed goes on front of the hole list. */ new_ptr->h_next = hp; hole_head = new_ptr; @@ -283,8 +282,8 @@ CHECKHOLES; } /* Block to be returned does not go on front of hole list. */ - prev_ptr = NIL_HOLE; - while (hp != NIL_HOLE && base > hp->h_base) { + prev_ptr = NULL; + while (hp != NULL && base > hp->h_base) { prev_ptr = hp; hp = hp->h_next; } @@ -336,7 +335,7 @@ register struct hole *hp; /* ptr to hole to merge with its successors */ /* If 'hp' points to the last hole, no merging is possible. If it does not, * try to absorb its successor into it and free the successor's table entry. */ - if ( (next_ptr = hp->h_next) == NIL_HOLE) return; + if ( (next_ptr = hp->h_next) == NULL) return; if (hp->h_base + hp->h_len == next_ptr->h_base) { hp->h_len += next_ptr->h_len; /* first one gets second one's mem */ del_slot(hp, next_ptr); @@ -347,7 +346,7 @@ register struct hole *hp; /* ptr to hole to merge with its successors */ /* If 'hp' now points to the last hole, return; otherwise, try to absorb its * successor into it. */ - if ( (next_ptr = hp->h_next) == NIL_HOLE) return; + if ( (next_ptr = hp->h_next) == NULL) return; if (hp->h_base + hp->h_len == next_ptr->h_base) { hp->h_len += next_ptr->h_len; del_slot(hp, next_ptr); @@ -378,8 +377,8 @@ struct memory *chunks; /* list of free memory chunks */ hp->h_next = hp + 1; hp->h_base = hp->h_len = 0; } - hole[_NR_HOLES-1].h_next = NIL_HOLE; - hole_head = NIL_HOLE; + hole[_NR_HOLES-1].h_next = NULL; + hole_head = NULL; free_slots = &hole[0]; addr_init(&addravl);