From: Sascha Wildner Date: Sun, 5 Apr 2009 22:52:17 +0000 (+0200) Subject: Generally use NULL instead of explicitly casting 0 to some pointer type (part2). X-Git-Tag: v2.3.1~152^2~11 X-Git-Url: https://gitweb.dragonflybsd.org/~uqs/games.git/commitdiff_plain/902ec341c3b5bf99157f7678cd693c791a8253ba Generally use NULL instead of explicitly casting 0 to some pointer type (part2). --- diff --git a/bin/mined/mined1.c b/bin/mined/mined1.c index e47dc85736..94d32334aa 100644 --- a/bin/mined/mined1.c +++ b/bin/mined/mined1.c @@ -480,11 +480,11 @@ VI(int u __unused) char new_file[LINE_LEN]; /* Buffer to hold new file name */ if (modified == TRUE && ask_save() == ERRORS) - return; + return; /* Get new file name */ if (get_file("Visit file:", new_file) == ERRORS) - return; + return; /* Free old linked list, initialize global variables and load new file */ initialize(); @@ -514,17 +514,17 @@ WT(void) /* Check if file_name is valid and if file can be written */ if (file_name[0] == '\0' || writable == FALSE) { - if (get_file("Enter file name:", file) != FINE) - return ERRORS; - copy_string(file_name, file); /* Save file name */ + if (get_file("Enter file name:", file) != FINE) + return ERRORS; + copy_string(file_name, file); /* Save file name */ } if ((fd = creat(file_name, 0644)) < 0) { /* Empty file */ - error("Cannot create ", file_name); - writable = FALSE; - return ERRORS; + error("Cannot create ", file_name); + writable = FALSE; + return ERRORS; } else - writable = TRUE; + writable = TRUE; clear_buffer(); @@ -534,20 +534,20 @@ WT(void) if (line->next == tail && line->text[0] == '\n') continue; } - if (writeline(fd, line->text) == ERRORS) { - count = -1L; - break; - } - count += (long) length_of(line->text); + if (writeline(fd, line->text) == ERRORS) { + count = -1L; + break; + } + count += (long) length_of(line->text); } if (count > 0L && flush_buffer(fd) == ERRORS) - count = -1L; + count = -1L; close(fd); if (count == -1L) - return ERRORS; + return ERRORS; modified = FALSE; rpipe = FALSE; /* File name is now assigned */ @@ -579,36 +579,36 @@ SH(int u __unused) if ((shell = getenv("SHELL")) == NIL_PTR) shell = "/bin/sh"; switch (pid = fork()) { - case -1: /* Error */ - error("Cannot fork.", NIL_PTR); - return; - case 0: /* This is the child */ - set_cursor(0, ymax); - putchar('\n'); - flush(); - raw_mode(OFF); + case -1: /* Error */ + error("Cannot fork.", NIL_PTR); + return; + case 0: /* This is the child */ + set_cursor(0, ymax); + putchar('\n'); + flush(); + raw_mode(OFF); if (rpipe) { /* Fix stdin */ close (0); if (open("/dev/tty", 0) < 0) exit (126); } - execl(shell, shell, (char *) 0); - exit(127); /* Exit with 127 */ - default : /* This is the parent */ - signal(SIGINT, SIG_IGN); - signal(SIGQUIT, SIG_IGN); - do { - w = wait(&status); - } while (w != -1 && w != pid); + execl(shell, shell, NULL); + exit(127); /* Exit with 127 */ + default : /* This is the parent */ + signal(SIGINT, SIG_IGN); + signal(SIGQUIT, SIG_IGN); + do { + w = wait(&status); + } while (w != -1 && w != pid); } raw_mode(ON); RD(0); if ((status >> 8) == 127) /* Child died with 127 */ - error("Cannot exec ", shell); + 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", NIL_PTR); } /* @@ -620,11 +620,11 @@ LINE * proceed(LINE *line, int count) { if (count < 0) - while (count++ < 0 && line != header) - line = line->prev; + while (count++ < 0 && line != header) + line = line->prev; else - while (count-- > 0 && line != tail) - line = line->next; + while (count-- > 0 && line != tail) + line = line->next; return line; } @@ -656,19 +656,19 @@ bottom_line(FLAG revfl, const char *s1, const char *s2, char *inbuf, set_cursor(0, ymax); if (revfl == ON) { /* Print rev. start sequence */ #ifdef UNIX - tputs(SO, 0, _putchar); + tputs(SO, 0, _putchar); #else - string_print(rev_video); + string_print(rev_video); #endif /* UNIX */ - stat_visible = TRUE; + stat_visible = TRUE; } else /* Used as clear_status() */ - stat_visible = FALSE; + stat_visible = FALSE; string_print(buf); - + if (inbuf != NIL_PTR) - ret = input(inbuf, statfl); + ret = input(inbuf, statfl); /* Print normal video */ #ifdef UNIX @@ -679,12 +679,12 @@ bottom_line(FLAG revfl, const char *s1, const char *s2, char *inbuf, string_print(blank_line); /* Clear the rest of the line */ #endif /* UNIX */ if (inbuf != NIL_PTR) - set_cursor(0, ymax); + set_cursor(0, ymax); else - set_cursor(x, y); /* Set cursor back to old position */ + set_cursor(x, y); /* Set cursor back to old position */ flush(); /* Perform the actual write */ if (ret != FINE) - clear_status(); + clear_status(); return ret; } @@ -700,19 +700,19 @@ count_chars(LINE *line) /* Find begin of line on screen */ while (cnt < 0) { - if (is_tab(*textp++)) - cnt = tab(cnt); - else - cnt++; + if (is_tab(*textp++)) + cnt = tab(cnt); + else + cnt++; } /* Count number of chars left */ cnt = 0; while (*textp != '\n') { - if (is_tab(*textp++)) - cnt = tab(cnt); - else - cnt++; + if (is_tab(*textp++)) + cnt = tab(cnt); + else + cnt++; } return cnt; } @@ -737,60 +737,60 @@ move(int new_x, char *new_address, int new_y) /* Check for illegal values */ if (new_y < 0 || new_y > last_y) - return; + return; /* Adjust y-coordinate and cur_line */ if (new_y < y) - while (y != new_y) { + while (y != new_y) { if(line->shift_count>0) { line->shift_count=0; move_to(0,y); string_print(blank_line); line_print(line); } - y--; - line = line->prev; - } + y--; + line = line->prev; + } else - while (y != new_y) { + while (y != new_y) { if(line->shift_count>0) { line->shift_count=0; move_to(0,y); string_print(blank_line); line_print(line); } - y++; - line = line->next; - } + y++; + line = line->next; + } /* Set or unset relative x-coordinate */ if (new_address == NIL_PTR) { - new_address = find_address(line, (new_x == x) ? rel_x : new_x , &tx); + new_address = find_address(line, (new_x == x) ? rel_x : new_x , &tx); if (new_x != x) rel_x = tx; - new_x = tx; + new_x = tx; } else { - rel_x = new_x = find_x(line, new_address); + rel_x = new_x = find_x(line, new_address); } /* Adjust shift_count if new_x lower than 0 or higher than XBREAK */ if (new_x < 0 || new_x >= XBREAK) { - if (new_x > XBREAK || (new_x == XBREAK && *new_address != '\n')) - shift = (new_x - XBREAK) / SHIFT_SIZE + 1; - else { - shift = new_x / SHIFT_SIZE; + if (new_x > XBREAK || (new_x == XBREAK && *new_address != '\n')) + shift = (new_x - XBREAK) / SHIFT_SIZE + 1; + else { + shift = new_x / SHIFT_SIZE; if (new_x % SHIFT_SIZE) shift--; - } - - if (shift != 0) { - line->shift_count += shift; - new_x = find_x(line, new_address); - set_cursor(0, y); - line_print(line); - rel_x = new_x; - } + } + + if (shift != 0) { + line->shift_count += shift; + new_x = find_x(line, new_address); + set_cursor(0, y); + line_print(line); + rel_x = new_x; + } } /* Assign and position cursor */ @@ -811,10 +811,10 @@ find_x(LINE *line, char *address) int nx = get_shift(line->shift_count) * -SHIFT_SIZE; while (textp != address && *textp != '\0') { - if (is_tab(*textp++)) /* Expand tabs */ - nx = tab(nx); - else - nx++; + if (is_tab(*textp++)) /* Expand tabs */ + nx = tab(nx); + else + nx++; } return nx; } @@ -830,17 +830,17 @@ find_address(LINE *line, int x_coord, int *old_x) int tx = get_shift(line->shift_count) * -SHIFT_SIZE; while (tx < x_coord && *textp != '\n') { - if (is_tab(*textp)) { - if (*old_x - x_coord == 1 && tab(tx) > x_coord) - break; /* Moving left over tab */ - else - tx = tab(tx); - } - else - tx++; - textp++; + if (is_tab(*textp)) { + if (*old_x - x_coord == 1 && tab(tx) > x_coord) + break; /* Moving left over tab */ + else + tx = tab(tx); + } + else + tx++; + textp++; } - + *old_x = tx; return textp; } @@ -855,8 +855,8 @@ length_of(char *string) int count = 0; if (string != NIL_PTR) { - while (*string++ != '\0') - count++; + while (*string++ != '\0') + count++; } return count; } @@ -869,7 +869,7 @@ void copy_string(char *to, const char *from) { while ((*to++ = *from++) != 0) - ; + ; } /* @@ -887,7 +887,7 @@ reset(LINE *head_line, int screen_y) /* Search for bot_line (might be last line in file) */ for (last_y = 0; last_y < nlines - 1 && last_y < screenmax && line->next != tail; last_y++) - line = line->next; + line = line->next; bot_line = line; y = (screen_y > last_y) ? last_y : screen_y; @@ -935,7 +935,7 @@ getchar(void) char c; if (read(input_fd, &c, 1) != 1 && quit == FALSE) - panic("Can't read one char from fd #0"); + panic("Can't read one char from fd #0"); return c & 0377; #endif /* UNIX */ @@ -954,15 +954,15 @@ display(int x_coord, int y_coord, LINE *line, int count) /* Find new startline if count is negative */ if (count < 0) { - line = proceed(line, count); - count = -count; + line = proceed(line, count); + count = -count; } /* Print the lines */ while (line != tail && count-- >= 0) { line->shift_count=0; - line_print(line); - line = line->next; + line_print(line); + line = line->next; } /* Print the blank lines (if any) */ @@ -979,14 +979,14 @@ display(int x_coord, int y_coord, LINE *line, int count) } /* - * Write_char does a buffered output. + * Write_char does a buffered output. */ int write_char(int fd, char c) { screen [out_count++] = c; if (out_count == SCREEN_SIZE) /* Flush on SCREEN_SIZE chars */ - return flush_buffer(fd); + return flush_buffer(fd); return FINE; } @@ -997,8 +997,8 @@ int writeline(int fd, const char *text) { while(*text) - if (write_char(fd, *text++) == ERRORS) - return ERRORS; + if (write_char(fd, *text++) == ERRORS) + return ERRORS; return FINE; } @@ -1022,29 +1022,29 @@ put_line(LINE *line, int offset, FLAG clear_line) /* Skip all chars as indicated by the offset and the shift_count field */ while (count < offset) { - if (is_tab(*textp++)) - count = tab(count); - else - count++; + if (is_tab(*textp++)) + count = tab(count); + else + count++; } while (*textp != '\n' && count < XBREAK) { - if (is_tab(*textp)) { /* Expand tabs to spaces */ - tab_count = tab(count); - while (count < XBREAK && count < tab_count) { - count++; - putchar(' '); - } - textp++; - } - else { + if (is_tab(*textp)) { /* Expand tabs to spaces */ + tab_count = tab(count); + while (count < XBREAK && count < tab_count) { + count++; + putchar(' '); + } + textp++; + } + else { if (*textp >= '\01' && *textp <= '\037') { #ifdef UNIX tputs(SO, 0, _putchar); #else string_print (rev_video); #endif /* UNIX */ - putchar(*textp++ + '\100'); + putchar(*textp++ + '\100'); #ifdef UNIX tputs(SE, 0, _putchar); #else @@ -1052,23 +1052,23 @@ put_line(LINE *line, int offset, FLAG clear_line) #endif /* UNIX */ } else - putchar(*textp++); - count++; - } + putchar(*textp++); + count++; + } } /* If line is longer than XBREAK chars, print the shift_mark */ if (count == XBREAK && *textp != '\n') - putchar(textp[1]=='\n' ? *textp : SHIFT_MARK); + putchar(textp[1]=='\n' ? *textp : SHIFT_MARK); /* Clear the rest of the line is clear_line is TRUE */ if (clear_line == TRUE) { #ifdef UNIX - tputs(CE, 0, _putchar); + tputs(CE, 0, _putchar); #else string_print(blank_line); #endif /* UNIX */ - putchar('\n'); + putchar('\n'); } } @@ -1079,17 +1079,17 @@ int flush_buffer(int fd) { if (out_count <= 0) /* There is nothing to flush */ - return FINE; + return FINE; #ifdef UNIX if (fd == STD_OUT) { - printf("%.*s", out_count, screen); - _flush(); + printf("%.*s", out_count, screen); + _flush(); } else #endif /* UNIX */ if (write(fd, screen, out_count) != out_count) { - bad_write(fd); - return ERRORS; + bad_write(fd); + return ERRORS; } clear_buffer(); /* Empty buffer */ return FINE; @@ -1102,12 +1102,12 @@ void bad_write(int fd) { if (fd == STD_OUT) /* Cannot write to terminal? */ - exit(1); - + exit(1); + clear_buffer(); build_string(text_buffer, "Command aborted: %s (File incomplete)", - (errno == ENOSPC || errno == -ENOSPC) ? - "No space on device" : "Write error"); + (errno == ENOSPC || errno == -ENOSPC) ? + "No space on device" : "Write error"); error(text_buffer, NIL_PTR); } @@ -1133,8 +1133,8 @@ abort_mined(void) /* Ask for confirmation */ status_line("Really abort? ", NIL_PTR); if (getchar() != 'y') { - clear_status(); - return; + clear_status(); + return; } /* Reset terminal */ @@ -1162,8 +1162,8 @@ raw_mode(FLAG state) static struct termios new_tty; if (state == OFF) { - tcsetattr(input_fd, TCSANOW, &old_tty); - return; + tcsetattr(input_fd, TCSANOW, &old_tty); + return; } /* Save old tty settings */ @@ -1200,9 +1200,9 @@ panic(const char *message) write(STD_OUT, text_buffer, length_of(text_buffer)); if (loading == FALSE) - XT(0); /* Check if file can be saved */ + XT(0); /* Check if file can be saved */ else - unlink(yank_file); + unlink(yank_file); raw_mode(OFF); #ifdef UNIX @@ -1292,7 +1292,7 @@ const char *normal_video = "\033[m"; /* String for leaving reverse video */ const char *blank_line = "\033[K"; /* Clear line to end */ #endif /* UNIX */ -/* +/* * Yank variables. */ FLAG yank_status = NOT_VALID; /* Status of yank_file */ @@ -1310,9 +1310,9 @@ initialize(void) /* Delete the whole list */ for (line = header->next; line != tail; line = next_line) { - next_line = line->next; - free_space(line->text); - free_space((char*)line); + next_line = line->next; + free_space(line->text); + free_space((char*)line); } /* header and tail should point to itself */ @@ -1331,15 +1331,15 @@ basename(char *path) char *last = NIL_PTR; while (*ptr != '\0') { - if (*ptr == '/') - last = ptr; - ptr++; + if (*ptr == '/') + last = ptr; + ptr++; } if (last == NIL_PTR) - return path; + return path; if (*(last + 1) == '\0') { /* E.g. /usr/tmp/pipo/ */ - *last = '\0'; - return basename(path);/* Try again */ + *last = '\0'; + return basename(path);/* Try again */ } return last + 1; } @@ -1363,7 +1363,7 @@ load_file(const char *file) writable = TRUE; /* Benefit of the doubt */ if (file == NIL_PTR) { if (rpipe == FALSE) - status_line("No file.", NIL_PTR); + status_line("No file.", NIL_PTR); else { fd = 0; file = "standard input"; @@ -1371,33 +1371,33 @@ load_file(const char *file) file_name[0] = '\0'; } else { - copy_string(file_name, file); /* Save file name */ - if (access(file, 0) < 0) /* Cannot access file. */ - status_line("New file ", file); - else if ((fd = open(file, 0)) < 0) - status_line("Cannot open ", file); - else if (access(file, 2) != 0) /* Set write flag */ - writable = FALSE; + copy_string(file_name, file); /* Save file name */ + if (access(file, 0) < 0) /* Cannot access file. */ + status_line("New file ", file); + else if ((fd = open(file, 0)) < 0) + status_line("Cannot open ", file); + else if (access(file, 2) != 0) /* Set write flag */ + writable = FALSE; } /* Read file */ loading = TRUE; /* Loading file, so set flag */ if (fd >= 0) { - status_line("Reading ", file); - while ((len = get_line(fd, text_buffer)) != ERRORS) { - line = line_insert(line, text_buffer, len); - nr_of_chars += (long) len; - } - if (nlines == 0) /* The file was empty! */ - line = line_insert(line, "\n", 1); - clear_buffer(); /* Clear output buffer */ - cur_line = header->next; - fstatus("Read", nr_of_chars); - close(fd); /* Close file */ + status_line("Reading ", file); + while ((len = get_line(fd, text_buffer)) != ERRORS) { + line = line_insert(line, text_buffer, len); + nr_of_chars += (long) len; + } + if (nlines == 0) /* The file was empty! */ + line = line_insert(line, "\n", 1); + clear_buffer(); /* Clear output buffer */ + cur_line = header->next; + fstatus("Read", nr_of_chars); + close(fd); /* Close file */ } else /* Just install a "\n" */ - line_insert(line, "\n", 1); + line_insert(line, "\n", 1); reset(header->next, 0); /* Initialize pointers */ @@ -1423,27 +1423,27 @@ get_line(int fd, char *buffer) char *begin = buffer; do { - if (cur_pos == last) { - if ((read_chars = read(fd, screen, SCREEN_SIZE)) <= 0) - break; - last = &screen[read_chars]; - cur_pos = screen; - } + if (cur_pos == last) { + if ((read_chars = read(fd, screen, SCREEN_SIZE)) <= 0) + break; + last = &screen[read_chars]; + cur_pos = screen; + } if (*cur_pos == '\0') *cur_pos = ' '; } while ((*buffer++ = *cur_pos++) != '\n'); current = cur_pos; if (read_chars <= 0) { - if (buffer == begin) - return ERRORS; - if (*(buffer - 1) != '\n') { - if (loading == TRUE) /* Add '\n' to last line of file */ - *buffer++ = '\n'; - else { - *buffer = '\0'; - return NO_LINE; - } + if (buffer == begin) + return ERRORS; + if (*(buffer - 1) != '\n') { + if (loading == TRUE) /* Add '\n' to last line of file */ + *buffer++ = '\n'; + else { + *buffer = '\0'; + return NO_LINE; + } } } @@ -1467,7 +1467,7 @@ install_line(const char *buffer, int length) return new_line; } -int +int main(int argc, char *argv[]) { /* mined is the Minix editor. */ @@ -1505,25 +1505,25 @@ main(int argc, char *argv[]) /* Load the file (if any) */ if (argc < 2) - load_file(NIL_PTR); + load_file(NIL_PTR); else { - get_file(NIL_PTR, argv[1]); /* Truncate filename */ - load_file(argv[1]); + get_file(NIL_PTR, argv[1]); /* Truncate filename */ + load_file(argv[1]); } /* Main loop of the editor. */ for (;;) { - index = getchar(); - if (stat_visible == TRUE) - clear_status(); - if (quit == TRUE) - abort_mined(); - else { /* Call the function for this key */ - (*key_map[index])(index); - flush(); /* Flush output (if any) */ - if (quit == TRUE) - quit = FALSE; - } + index = getchar(); + if (stat_visible == TRUE) + clear_status(); + if (quit == TRUE) + abort_mined(); + else { /* Call the function for this key */ + (*key_map[index])(index); + flush(); /* Flush output (if any) */ + if (quit == TRUE) + quit = FALSE; + } } /* NOTREACHED */ } @@ -1574,7 +1574,7 @@ void XT(int u __unused) { if (modified == TRUE && ask_save() == ERRORS) - return; + return; raw_mode(OFF); set_cursor(0, ymax); @@ -1617,8 +1617,8 @@ static void /* F6 = ESC [ 6 ~ */ /* F7 = ESC [ 17 ~ */ /* F8 = ESC [ 18 ~ */ - case '1': - switch (ch) { + case '1': + switch (ch) { case '~': return(SF); case '7': getchar(); return(MA); case '8': getchar(); return(CTL); @@ -1696,7 +1696,7 @@ static void } /* - * ESC() wants a count and a command after that. It repeats the + * ESC() wants a count and a command after that. It repeats the * command count times. If a ^\ is given during repeating, stop looping and * return to main loop. */ @@ -1709,9 +1709,9 @@ ESC(int u __unused) index = getchar(); while (index >= '0' && index <= '9' && quit == FALSE) { - count *= 10; - count += index - '0'; - index = getchar(); + count *= 10; + count += index - '0'; + index = getchar(); } if (count == 0) { count = 1; @@ -1723,19 +1723,19 @@ ESC(int u __unused) } if (func == I) { /* Function assigned? */ - clear_status(); - return; + clear_status(); + return; } while (count-- > 0 && quit == FALSE) { - if (stat_visible == TRUE) - clear_status(); - (*func)(index); - flush(); + if (stat_visible == TRUE) + clear_status(); + (*func)(index); + flush(); } if (quit == TRUE) /* Abort has been given */ - error("Aborted", NIL_PTR); + error("Aborted", NIL_PTR); } /* @@ -1750,17 +1750,17 @@ ask_save(void) " has been modified. Save? (y/n)"); while((c = getchar()) != 'y' && c != 'n' && quit == FALSE) { - ring_bell(); - flush(); + ring_bell(); + flush(); } clear_status(); if (c == 'y') - return WT(); + return WT(); if (c == 'n') - return FINE; + return FINE; quit = FALSE; /* Abort character has been given */ return ERRORS; @@ -1776,13 +1776,13 @@ line_number(void) int count = 1; while (line != cur_line) { - count++; - line = line->next; + count++; + line = line->next; } - + return count; } - + /* * Display a line telling how many chars and lines the file contains. Also tell * whether the file is readonly and/or modified. @@ -1799,26 +1799,26 @@ file_status(const char *message, long count, char *file, int lines, char yank_msg[LINE_LEN];/* Buffer for msg of yank_file */ if (count < 0) /* Not valid. Count chars in file */ - for (line = header->next; line != tail; line = line->next) - count += length_of(line->text); + for (line = header->next; line != tail; line = line->next) + count += length_of(line->text); if (yank_status != NOT_VALID) /* Append buffer info */ - build_string(yank_msg, " Buffer: %D char%s.", chars_saved, + build_string(yank_msg, " Buffer: %D char%s.", chars_saved, (chars_saved == 1L) ? "" : "s"); else - yank_msg[0] = '\0'; + yank_msg[0] = '\0'; build_string(msg, "%s %s%s%s %d line%s %D char%s.%s Line %d", message, - (rpipe == TRUE && *message != '[') ? "standard input" : basename(file), - (changed == TRUE) ? "*" : "", - (writefl == FALSE) ? " (Readonly)" : "", - lines, (lines == 1) ? "" : "s", + (rpipe == TRUE && *message != '[') ? "standard input" : basename(file), + (changed == TRUE) ? "*" : "", + (writefl == FALSE) ? " (Readonly)" : "", + lines, (lines == 1) ? "" : "s", count, (count == 1L) ? "" : "s", yank_msg, line_number()); if (length_of(msg) + 1 > LINE_LEN - 4) { - msg[LINE_LEN - 4] = SHIFT_MARK; /* Overflow on status line */ - msg[LINE_LEN - 3] = '\0'; + msg[LINE_LEN - 4] = SHIFT_MARK; /* Overflow on status line */ + msg[LINE_LEN - 3] = '\0'; } status_line(msg, NIL_PTR); /* Print the information */ } @@ -1836,27 +1836,27 @@ build_string(char *buf, const char *fmt, ...) va_start(argptr, fmt); while (*fmt) { - if (*fmt == '%') { - fmt++; - switch (*fmt++) { - case 's' : - scanp = va_arg(argptr, char *); - break; - case 'd' : - scanp = num_out((long) va_arg(argptr, int)); - break; - case 'D' : - scanp = num_out((long) va_arg(argptr, long)); - break; - default : - scanp = ""; - } - while ((*buf++ = *scanp++) != 0) - ; - buf--; - } - else - *buf++ = *fmt++; + if (*fmt == '%') { + fmt++; + switch (*fmt++) { + case 's' : + scanp = va_arg(argptr, char *); + break; + case 'd' : + scanp = num_out((long) va_arg(argptr, int)); + break; + case 'D' : + scanp = num_out((long) va_arg(argptr, long)); + break; + default : + scanp = ""; + } + while ((*buf++ = *scanp++) != 0) + ; + buf--; + } + else + *buf++ = *fmt++; } va_end(argptr); *buf = '\0'; @@ -1876,18 +1876,18 @@ num_out(long number) int i; for (i = 0; i < 10; i++) { - digit = number / pow; /* Get next digit */ - if (digit == 0L && digit_seen == FALSE && i != 9) - num_buf[i] = ' '; - else { - num_buf[i] = '0' + (char) digit; - number -= digit * pow; /* Erase digit */ - digit_seen = TRUE; - } - pow /= 10L; /* Get next digit */ + digit = number / pow; /* Get next digit */ + if (digit == 0L && digit_seen == FALSE && i != 9) + num_buf[i] = ' '; + else { + num_buf[i] = '0' + (char) digit; + number -= digit * pow; /* Erase digit */ + digit_seen = TRUE; + } + pow /= 10L; /* Get next digit */ } for (i = 0; num_buf[i] == ' '; i++) /* Skip leading spaces */ - ; + ; return (&num_buf[i]); } @@ -1906,20 +1906,20 @@ get_number(const char *message, int *result) index = getchar(); if (quit == FALSE && (index < '0' || index > '9')) { - error("Bad count", NIL_PTR); - return ERRORS; + error("Bad count", NIL_PTR); + return ERRORS; } /* Convert input to a decimal number */ while (index >= '0' && index <= '9' && quit == FALSE) { - count *= 10; - count += index - '0'; - index = getchar(); + count *= 10; + count += index - '0'; + index = getchar(); } if (quit == TRUE) { - clear_status(); - return ERRORS; + clear_status(); + return ERRORS; } *result = count; @@ -1940,54 +1940,54 @@ input(char *inbuf, FLAG clearfl) *ptr = '\0'; while (quit == FALSE) { - flush(); - switch (c = getchar()) { - case '\b' : /* Erase previous char */ - if (ptr > inbuf) { - ptr--; + flush(); + switch (c = getchar()) { + case '\b' : /* Erase previous char */ + if (ptr > inbuf) { + ptr--; #ifdef UNIX - tputs(SE, 0, _putchar); + tputs(SE, 0, _putchar); #else - string_print(normal_video); + string_print(normal_video); #endif /* UNIX */ - if (is_tab(*ptr)) - string_print(" \b\b\b \b\b"); - else - string_print(" \b\b \b"); + if (is_tab(*ptr)) + string_print(" \b\b\b \b\b"); + else + string_print(" \b\b \b"); #ifdef UNIX - tputs(SO, 0, _putchar); + tputs(SO, 0, _putchar); #else - string_print(rev_video); + string_print(rev_video); #endif /* UNIX */ - string_print(" \b"); - *ptr = '\0'; - } - else - ring_bell(); - break; - case '\n' : /* End of input */ - /* If inbuf is empty clear status_line */ - return (ptr == inbuf && clearfl == TRUE) ? NO_INPUT :FINE; - default : /* Only read ASCII chars */ - if ((c >= ' ' && c <= '~') || c == '\t') { - *ptr++ = c; - *ptr = '\0'; - if (c == '\t') - string_print("^I"); - else - putchar(c); - string_print(" \b"); - } - else - ring_bell(); - } + string_print(" \b"); + *ptr = '\0'; + } + else + ring_bell(); + break; + case '\n' : /* End of input */ + /* If inbuf is empty clear status_line */ + return (ptr == inbuf && clearfl == TRUE) ? NO_INPUT :FINE; + default : /* Only read ASCII chars */ + if ((c >= ' ' && c <= '~') || c == '\t') { + *ptr++ = c; + *ptr = '\0'; + if (c == '\t') + string_print("^I"); + else + putchar(c); + string_print(" \b"); + } + else + ring_bell(); + } } quit = FALSE; return ERRORS; } /* - * Get_file() reads a filename from the terminal. Filenames longer than + * Get_file() reads a filename from the terminal. Filenames longer than * FILE_LENGHT chars are truncated. */ int @@ -1997,8 +1997,8 @@ get_file(const char *message, char *file) int ret = FINE; if (message == NIL_PTR || (ret = get_string(message, file, TRUE)) == FINE) { - if (length_of((ptr = basename(file))) > NAME_MAX) - ptr[NAME_MAX] = '\0'; + if (length_of((ptr = basename(file))) > NAME_MAX) + ptr[NAME_MAX] = '\0'; } return ret; } @@ -2040,8 +2040,8 @@ get_term(void) char entry[1024]; if (tgetent(entry, getenv("TERM")) <= 0) { - printf("Unknown terminal.\n"); - exit(1); + printf("Unknown terminal.\n"); + exit(1); } AL = tgetstr("al", &loc); @@ -2055,8 +2055,8 @@ get_term(void) screenmax = ymax - 1; if (!CE || !SO || !SE || !CL || !AL || !CM) { - printf("Sorry, no mined on this type of terminal\n"); - exit(1); + printf("Sorry, no mined on this type of terminal\n"); + exit(1); } } #endif /* UNIX */ diff --git a/games/hack/hack.apply.c b/games/hack/hack.apply.c index 04989ae4ee..c4d6fc11a2 100644 --- a/games/hack/hack.apply.c +++ b/games/hack/hack.apply.c @@ -136,7 +136,7 @@ in_ice_box(struct obj *obj) pline("Your weapon is welded to your hand!"); return(0); } - setuwep((struct obj *) 0); + setuwep(NULL); } current_ice_box->owt += obj->owt; freeinv(obj); @@ -182,7 +182,7 @@ struct obj *otmp; else { pline("Do you want to take something out of the ice-box? [yn] "); if(readchar() == 'y') - if(askchain(fcobj, (char *) 0, 0, out_ice_box, ck_ice_box, 0)) + if(askchain(fcobj, NULL, 0, out_ice_box, ck_ice_box, 0)) return; pline("That was all. Do you wish to put something in? [yn] "); if(readchar() != 'y') return; @@ -196,7 +196,7 @@ struct obj *otmp; static struct monst * bchit(int ddx, int ddy, int range, char sym) { - struct monst *mtmp = (struct monst *) 0; + struct monst *mtmp = NULL; int bchx = u.ux, bchy = u.uy; if(sym) Tmp_at(-1, sym); /* open call */ @@ -412,7 +412,7 @@ use_pick_axe(struct obj *obj) && !sobj_at(ENORMOUS_ROCK, rx, ry)) { /* ACCESSIBLE or POOL */ pline("You swing your %s through thin air.", - aobjnam(obj, (char *) 0)); + aobjnam(obj, NULL)); } else { if(dig_pos.x != rx || dig_pos.y != ry || dig_level != dlevel || dig_down) { diff --git a/games/hack/hack.cmd.c b/games/hack/hack.cmd.c index cee0571433..69367a7790 100644 --- a/games/hack/hack.cmd.c +++ b/games/hack/hack.cmd.c @@ -81,7 +81,7 @@ struct func_tab cmdlist[]={ struct ext_func_tab extcmdlist[] = { { "dip", dodip }, { "pray", dopray }, - { (char *) 0, donull } + { NULL, donull } }; extern char quitchars[]; diff --git a/games/hack/hack.do.c b/games/hack/hack.do.c index 6584eeb9db..a9a413fbc5 100644 --- a/games/hack/hack.do.c +++ b/games/hack/hack.do.c @@ -45,7 +45,7 @@ drop(struct obj *obj) pline("Your weapon is welded to your hand!"); return(0); } - setuwep((struct obj *) 0); + setuwep(NULL); } pline("You dropped %s.", doname(obj)); dropx(obj); @@ -279,7 +279,7 @@ dothrow(void) if(obj->quan > 1) setuwep(splitobj(obj, 1)); else - setuwep((struct obj *) 0); + setuwep(NULL); } else if(obj->quan > 1) splitobj(obj, 1); @@ -303,14 +303,14 @@ dothrow(void) pline("%s hits the floor.", Doname(obj)); if(obj->otyp == EXPENSIVE_CAMERA) { pline("It is shattered in a thousand pieces!"); - obfree(obj, Null(obj)); + obfree(obj, NULL); } else if(obj->otyp == EGG) { pline("\"Splash!\""); - obfree(obj, Null(obj)); + obfree(obj, NULL); } else if(obj->olet == POTION_SYM) { pline("The flask breaks, and you smell a peculiar odor ..."); potionbreathe(obj); - obfree(obj, Null(obj)); + obfree(obj, NULL); } else { dropy(obj); } @@ -357,7 +357,7 @@ dothrow(void) /* weapons thrown disappear sometimes */ if(obj->otyp < BOOMERANG && rn2(3)) { /* check bill; free */ - obfree(obj, (struct obj *) 0); + obfree(obj, NULL); return(1); } } else miss(objects[obj->otyp].oc_name, mon); diff --git a/games/hack/hack.do_name.c b/games/hack/hack.do_name.c index 202d7fe0f7..ff166314e1 100644 --- a/games/hack/hack.do_name.c +++ b/games/hack/hack.do_name.c @@ -121,7 +121,7 @@ char buf[BUFSZ]; otmp2->onamelth = lth; strcpy(ONAME(otmp2), buf); - setworn((struct obj *) 0, obj->owornmask); + setworn(NULL, obj->owornmask); setworn(otmp2, otmp2->owornmask); /* do freeinv(obj); etc. by hand in order to preserve diff --git a/games/hack/hack.do_wear.c b/games/hack/hack.do_wear.c index 3d2a373b08..310d7e268f 100644 --- a/games/hack/hack.do_wear.c +++ b/games/hack/hack.do_wear.c @@ -100,7 +100,7 @@ armoroff(struct obj *otmp) { int delay = -objects[otmp->otyp].oc_delay; if(cursed(otmp)) return(0); - setworn((struct obj *) 0, otmp->owornmask & W_ARMOR); + setworn(NULL, otmp->owornmask & W_ARMOR); if(delay) { nomul(delay); switch(otmp->otyp) { @@ -170,7 +170,7 @@ doweararm(void) if(err) return(0); setworn(otmp, mask); if(otmp == uwep) - setuwep((struct obj *) 0); + setuwep(NULL); delay = -objects[otmp->otyp].oc_delay; if(delay){ nomul(delay); @@ -226,7 +226,7 @@ dowearring(void) } while(!mask); setworn(otmp, mask); if(otmp == uwep) - setuwep((struct obj *) 0); + setuwep(NULL); oldprop = u.uprops[PROP(otmp->otyp)].p_flgs; u.uprops[PROP(otmp->otyp)].p_flgs |= mask; switch(otmp->otyp){ @@ -256,7 +256,7 @@ ringoff(struct obj *obj) { long mask; mask = obj->owornmask & W_RING; - setworn((struct obj *) 0, obj->owornmask); + setworn(NULL, obj->owornmask); if(!(u.uprops[PROP(obj->otyp)].p_flgs & mask)) impossible("Strange... I didn't know you had that ring."); u.uprops[PROP(obj->otyp)].p_flgs &= ~mask; @@ -314,18 +314,18 @@ int xfl = 0; pline("Your %s off your fingers.", (uleft && uright) ? "rings slip" : "ring slips"); xfl++; - if((otmp = uleft) != Null(obj)){ + if((otmp = uleft) != NULL){ ringoff(uleft); dropx(otmp); } - if((otmp = uright) != Null(obj)){ + if((otmp = uright) != NULL){ ringoff(uright); dropx(otmp); } } - if((otmp = uwep) != Null(obj)){ + if((otmp = uwep) != NULL){ /* Note: at present also cursed weapons fall */ - setuwep((struct obj *) 0); + setuwep(NULL); dropx(otmp); pline("Your weapon %sslips from your hands.", xfl ? "also " : ""); diff --git a/games/hack/hack.dog.c b/games/hack/hack.dog.c index b5f97c0b22..f183ee9f1d 100644 --- a/games/hack/hack.dog.c +++ b/games/hack/hack.dog.c @@ -415,7 +415,7 @@ tamedog(struct monst *mtmp, struct obj *obj) pline("%s devours the %s.", Monnam(mtmp), objects[obj->otyp].oc_name); } - obfree(obj, (struct obj *) 0); + obfree(obj, NULL); } mtmp2 = newmonst(sizeof(struct edog) + mtmp->mnamelth); *mtmp2 = *mtmp; diff --git a/games/hack/hack.eat.c b/games/hack/hack.eat.c index ff985cacaf..a2e4814961 100644 --- a/games/hack/hack.eat.c +++ b/games/hack/hack.eat.c @@ -142,7 +142,7 @@ gotit: goto no_opener; } pline("Using your %s you try to open the tin.", - aobjnam(uwep, (char *) 0)); + aobjnam(uwep, NULL)); } else { no_opener: pline("It is not so easy to open this tin."); diff --git a/games/hack/hack.end.c b/games/hack/hack.end.c index 5a96e476dc..db6b8d717f 100644 --- a/games/hack/hack.end.c +++ b/games/hack/hack.end.c @@ -132,7 +132,7 @@ done(const char *st1) outrip(); } if(*st1 == 'c') killer = st1; /* after outrip() */ - settty((char *) 0); /* does a clear_screen() */ + settty(NULL); /* does a clear_screen() */ if(!done_stopprint) printf("Goodbye %s %s...\n\n", pl_character, plname); { long int tmp; diff --git a/games/hack/hack.engrave.c b/games/hack/hack.engrave.c index 5e5121d3f9..78674460a5 100644 --- a/games/hack/hack.engrave.c +++ b/games/hack/hack.engrave.c @@ -31,7 +31,7 @@ struct engr *ep = head_engr; return(ep); ep = ep->nxt_engr; } - return((struct engr *) 0); + return(NULL); } bool @@ -159,7 +159,7 @@ struct obj *otmp; if(uwep && uwep->cursed) { /* Andreas Bormann */ pline("Since your weapon is welded to your hand,"); - pline("you use the %s.", aobjnam(uwep, (char *) 0)); + pline("you use the %s.", aobjnam(uwep, NULL)); otmp = uwep; } else { if(!otmp) diff --git a/games/hack/hack.fight.c b/games/hack/hack.fight.c index 23cd22de12..4f284d0f42 100644 --- a/games/hack/hack.fight.c +++ b/games/hack/hack.fight.c @@ -164,8 +164,8 @@ hmon(struct monst *mon, struct obj *obj, int thrown) pline("As you hit %s, the boomerang breaks into splinters.", monnam(mon)); freeinv(obj); - setworn((struct obj *) 0, obj->owornmask); - obfree(obj, (struct obj *) 0); + setworn(NULL, obj->owornmask); + obfree(obj, NULL); tmp++; } } @@ -179,8 +179,8 @@ hmon(struct monst *mon, struct obj *obj, int thrown) pline("You succeed in destroying your camera. Congratulations!"); freeinv(obj); if(obj->owornmask) - setworn((struct obj *) 0, obj->owornmask); - obfree(obj, (struct obj *) 0); + setworn(NULL, obj->owornmask); + obfree(obj, NULL); return(TRUE); case DEAD_COCKATRICE: pline("You hit %s with the cockatrice corpse.", diff --git a/games/hack/hack.h b/games/hack/hack.h index 598c57685d..27cd816424 100644 --- a/games/hack/hack.h +++ b/games/hack/hack.h @@ -17,8 +17,6 @@ #define rindex strrchr #endif /* BSD */ -#define Null(type) ((struct type *) 0) - #include "def.objclass.h" typedef struct { diff --git a/games/hack/hack.invent.c b/games/hack/hack.invent.c index bae77186d4..e61f80bc38 100644 --- a/games/hack/hack.invent.c +++ b/games/hack/hack.invent.c @@ -105,7 +105,7 @@ useup(struct obj *obj) } else { setnotworn(obj); freeinv(obj); - obfree(obj, (struct obj *) 0); + obfree(obj, NULL); } } @@ -129,7 +129,7 @@ delobj(struct obj *obj) { freeobj(obj); unpobj(obj); - obfree(obj, (struct obj *) 0); + obfree(obj, NULL); } /* unlink obj from chain starting with fobj */ @@ -250,7 +250,7 @@ o_on(unsigned int id, struct obj *objchn) if(objchn->o_id == id) return(objchn); objchn = objchn->nobj; } - return((struct obj *) 0); + return(NULL); } struct trap * @@ -293,7 +293,7 @@ mkgoldobj(long q) /* * getobj returns: * struct obj *xxx: object to do something with. - * (struct obj *) 0 error return: no object. + * NULL error return: no object. * &zeroobj explicitly no object (as in w-). */ struct obj * @@ -387,7 +387,7 @@ getobj(const char *let, const char *word) if(index(quitchars,ilet)) return(NULL); if(ilet == '-') { - return(allownone ? &zeroobj : (struct obj *) 0); + return(allownone ? &zeroobj : NULL); } if(ilet == '$') { if(!allowgold){ @@ -403,7 +403,7 @@ getobj(const char *let, const char *word) if(!(ilet = morc)) continue; /* he typed a letter (not a space) to more() */ } else if(ilet == '*') { - doinv((char *) 0); + doinv(NULL); if(!(ilet = morc)) continue; /* ... */ } @@ -597,7 +597,7 @@ xprname(struct obj *obj, char let) int ddoinv(void) { - doinv((char *) 0); + doinv(NULL); return(0); } @@ -618,7 +618,7 @@ doinv(char *lets) return; } - cornline(0, (char *) 0); + cornline(0, NULL); ilet = 'a'; for(otmp = invent; otmp; otmp = otmp->nobj) { if(flags.invlet_constant) ilet = otmp->invlet; @@ -757,10 +757,10 @@ dolook(void) if(ct == 1 && !gold) { pline("You %s here %s.", verb, doname(otmp0)); - cornline(3, (char *) 0); + cornline(3, NULL); } if(ct > 1) - cornline(2, (char *) 0); + cornline(2, NULL); return(!!Blind); } diff --git a/games/hack/hack.ioctl.c b/games/hack/hack.ioctl.c index c4b5439bb7..e63465c6a2 100644 --- a/games/hack/hack.ioctl.c +++ b/games/hack/hack.ioctl.c @@ -43,7 +43,7 @@ dosuspend(void) { #ifdef SIGTSTP if(signal(SIGTSTP, SIG_IGN) == SIG_DFL) { - settty((char *) 0); + settty(NULL); signal(SIGTSTP, SIG_DFL); kill(0, SIGTSTP); gettty(); diff --git a/games/hack/hack.main.c b/games/hack/hack.main.c index 909ba3cf73..7afee557a8 100644 --- a/games/hack/hack.main.c +++ b/games/hack/hack.main.c @@ -381,7 +381,7 @@ not_recovered: #ifdef MAIL ckmailstatus(); #endif - rhack((char *) 0); + rhack(NULL); } if(multi && multi%7 == 0) fflush(stdout); diff --git a/games/hack/hack.makemon.c b/games/hack/hack.makemon.c index 9a510e4523..673b120b0c 100644 --- a/games/hack/hack.makemon.c +++ b/games/hack/hack.makemon.c @@ -21,9 +21,9 @@ makemon(struct permonst *ptr, int x, int y) int tmp, ct; boolean anything = (!ptr); - if(x != 0 || y != 0) if(m_at(x,y)) return((struct monst *) 0); + if(x != 0 || y != 0) if(m_at(x,y)) return(NULL); if(ptr){ - if(index(fut_geno, ptr->mlet)) return((struct monst *) 0); + if(index(fut_geno, ptr->mlet)) return(NULL); } else { ct = CMNUM - strlen(fut_geno); if(index(fut_geno, 'm')) ct++; /* make only 1 minotaur */ diff --git a/games/hack/hack.mklev.c b/games/hack/hack.mklev.c index 1ea8096003..aeb28b2d4d 100644 --- a/games/hack/hack.mklev.c +++ b/games/hack/hack.mklev.c @@ -95,7 +95,7 @@ makelevel(void) while a monster was on the stairs. Conclusion: we have to check for monsters on the stairs anyway. */ if(!rn2(3)) - makemon((struct permonst *) 0, somex(), somey()); + makemon(NULL, somex(), somey()); /* put traps and mimics inside */ goldseen = FALSE; diff --git a/games/hack/hack.mkmaze.c b/games/hack/hack.mkmaze.c index 24c24940cb..9c6c7fc39c 100644 --- a/games/hack/hack.mkmaze.c +++ b/games/hack/hack.mkmaze.c @@ -75,14 +75,14 @@ makemaz(void) makemon(PM_MINOTAUR, mm.x, mm.y); for(x = rn1(5,7); x; x--) { mm = mazexy(); - makemon((struct permonst *) 0, mm.x, mm.y); + makemon(NULL, mm.x, mm.y); } for(x = rn1(6,7); x; x--) { mm = mazexy(); mkgold(0L,mm.x,mm.y); } for(x = rn1(6,7); x; x--) - mktrap(0,1,(struct mkroom *) 0); + mktrap(0,1,NULL); mm = mazexy(); levl[(xupstair = mm.x)][(yupstair = mm.y)].scrsym = '<'; levl[xupstair][yupstair].typ = STAIRS; diff --git a/games/hack/hack.mkshop.c b/games/hack/hack.mkshop.c index 8c62b6633b..239ddaed05 100644 --- a/games/hack/hack.mkshop.c +++ b/games/hack/hack.mkshop.c @@ -174,7 +174,7 @@ mkzoo(int type) (sy == sroom->hy && doors[sh].y == sy+1)) continue; mon = makemon( (type == MORGUE) ? morguemon() : - (type == BEEHIVE) ? PM_KILLER_BEE : (struct permonst *) 0, + (type == BEEHIVE) ? PM_KILLER_BEE : NULL, sx, sy); if(mon) mon->msleep = 1; switch(type) { diff --git a/games/hack/hack.o_init.c b/games/hack/hack.o_init.c index 77c2bf97de..fb64b355dc 100644 --- a/games/hack/hack.o_init.c +++ b/games/hack/hack.o_init.c @@ -156,9 +156,9 @@ dodiscovered(void) /* free after Robert Viduya */ } if (ct == 0) { pline ("You haven't discovered anything yet..."); - cornline(3, (char *) 0); + cornline(3, NULL); } else - cornline(2, (char *) 0); + cornline(2, NULL); return(0); } diff --git a/games/hack/hack.pager.c b/games/hack/hack.pager.c index 7c411066e3..bb0eccb96e 100644 --- a/games/hack/hack.pager.c +++ b/games/hack/hack.pager.c @@ -316,7 +316,7 @@ page_file(const char *fnam, bool silent) if(dup(fd)) { if(!silent) printf("Cannot open %s as stdin.\n", fnam); } else { - execl(catmore, "page", (char *) 0); + execl(catmore, "page", NULL); if(!silent) printf("Cannot exec %s.\n", catmore); } exit(1); @@ -327,7 +327,7 @@ page_file(const char *fnam, bool silent) { FILE *f; /* free after Robert Viduya */ - if ((f = fopen (fnam, "r")) == (FILE *) 0) { + if ((f = fopen (fnam, "r")) == NULL) { if(!silent) { home(); perror (fnam); flags.toplin = 1; pline ("Cannot open %s.", fnam); @@ -349,9 +349,9 @@ dosh(void) char *str; if(child(0)) { if((str = getenv("SHELL"))) - execl(str, str, (char *) 0); + execl(str, str, NULL); else - execl("/bin/sh", "sh", (char *) 0); + execl("/bin/sh", "sh", NULL); pline("sh: cannot execute."); exit(1); } @@ -386,7 +386,7 @@ child(bool wt) f = fork(); if(f == 0){ /* child */ - settty((char *) 0); /* also calls end_screen() */ + settty(NULL); /* also calls end_screen() */ /* revoke */ setgid(getgid()); #ifdef CHDIR diff --git a/games/hack/hack.potion.c b/games/hack/hack.potion.c index 6245cf2fe6..10a9f7bd73 100644 --- a/games/hack/hack.potion.c +++ b/games/hack/hack.potion.c @@ -290,7 +290,7 @@ potionhit(struct monst *mon, struct obj *obj) } if(uclose && rn2(5)) potionbreathe(obj); - obfree(obj, Null(obj)); + obfree(obj, NULL); } void diff --git a/games/hack/hack.read.c b/games/hack/hack.read.c index 8c898b7229..a3e0931631 100644 --- a/games/hack/hack.read.c +++ b/games/hack/hack.read.c @@ -136,7 +136,7 @@ doread(void) free((char *) uchain); uball->spe = 0; uball->owornmask &= ~W_BALL; - uchain = uball = (struct obj *) 0; + uchain = uball = NULL; } break; } @@ -147,7 +147,7 @@ doread(void) if(confused) cnt += 12; while(cnt--) makemon(confused ? PM_ACID_BLOB : - (struct permonst *) 0, u.ux, u.uy); + NULL, u.ux, u.uy); break; } case SCR_ENCHANT_WEAPON: @@ -175,7 +175,7 @@ doread(void) for(i = -bd; i <= bd; i++) for(j = -bd; j <= bd; j++) if((mtmp = m_at(u.ux+i, u.uy+j))) - tamedog(mtmp, (struct obj *) 0); + tamedog(mtmp, NULL); break; } case SCR_GENOCIDE: diff --git a/games/hack/hack.rumors.c b/games/hack/hack.rumors.c index a251e14693..586a4c3470 100644 --- a/games/hack/hack.rumors.c +++ b/games/hack/hack.rumors.c @@ -53,7 +53,7 @@ outrumor(void) int rn,i; FILE *rumf; if(n_rumors <= n_used_rumors || - (rumf = fopen(RUMORFILE, "r")) == (FILE *) 0) return; + (rumf = fopen(RUMORFILE, "r")) == NULL) return; if(n_used_rumors < 0) init_rumors(rumf); if(!n_rumors) goto none; rn = rn2(n_rumors - n_used_rumors); diff --git a/games/hack/hack.steal.c b/games/hack/hack.steal.c index 615681c71e..2ed80888e1 100644 --- a/games/hack/hack.steal.c +++ b/games/hack/hack.steal.c @@ -105,7 +105,7 @@ steal(struct monst *mtmp) break; case ARMOR_SYM: if(multi < 0 || otmp == uarms){ - setworn((struct obj *) 0, otmp->owornmask & W_ARMOR); + setworn(NULL, otmp->owornmask & W_ARMOR); break; } { int curssv = otmp->cursed; @@ -133,7 +133,7 @@ steal(struct monst *mtmp) } } else if(otmp == uwep) - setuwep((struct obj *) 0); + setuwep(NULL); if(otmp->olet == CHAIN_SYM) { impossible("How come you are carrying that chain?"); } @@ -141,9 +141,9 @@ steal(struct monst *mtmp) Punished = 0; freeobj(uchain); free((char *) uchain); - uchain = (struct obj *) 0; + uchain = NULL; uball->spe = 0; - uball = (struct obj *) 0; /* superfluous */ + uball = NULL; /* superfluous */ } freeinv(otmp); pline("%s stole %s.", named ? "She" : Monnam(mtmp), doname(otmp)); @@ -166,7 +166,7 @@ stealamulet(struct monst *mtmp) for(otmp = invent; otmp; otmp = otmp->nobj) { if(otmp->olet == AMULET_SYM) { /* might be an imitation one */ - if(otmp == uwep) setuwep((struct obj *) 0); + if(otmp == uwep) setuwep(NULL); freeinv(otmp); mpickobj(mtmp,otmp); pline("%s stole %s!", Monnam(mtmp), doname(otmp)); @@ -192,7 +192,7 @@ relobj(struct monst *mtmp, int show) if(show & cansee(mtmp->mx,mtmp->my)) atl(otmp->ox,otmp->oy,otmp->olet); } - mtmp->minvent = (struct obj *) 0; + mtmp->minvent = NULL; if(mtmp->mgold || mtmp->data->mlet == 'L') { long tmp; diff --git a/games/hack/hack.tty.c b/games/hack/hack.tty.c index 92152063a0..a1ced1e449 100644 --- a/games/hack/hack.tty.c +++ b/games/hack/hack.tty.c @@ -183,7 +183,7 @@ error(const char *s, ...) { va_list ap; if(settty_needed) - settty((char *) 0); + settty(NULL); va_start(ap, s); vprintf(s, ap); va_end(ap); diff --git a/games/hack/hack.unix.c b/games/hack/hack.unix.c index 20f12ce9a7..318d88b353 100644 --- a/games/hack/hack.unix.c +++ b/games/hack/hack.unix.c @@ -387,7 +387,7 @@ readmail(void) if(!(mr = getenv("MAILREADER"))) mr = DEF_MAILREADER; if(child(1)){ - execl(mr, mr, (char *) 0); + execl(mr, mr, NULL); exit(1); } #else /* DEF_MAILREADER */ diff --git a/games/hack/hack.wield.c b/games/hack/hack.wield.c index 5b0538bbee..fcee58eebc 100644 --- a/games/hack/hack.wield.c +++ b/games/hack/hack.wield.c @@ -29,7 +29,7 @@ dowield(void) if(uwep == 0){ pline("You are already empty handed."); } else { - setuwep((struct obj *) 0); + setuwep(NULL); res++; pline("You are empty handed."); } diff --git a/games/hack/hack.zap.c b/games/hack/hack.zap.c index 3e6306e3b0..f2bfa982c8 100644 --- a/games/hack/hack.zap.c +++ b/games/hack/hack.zap.c @@ -166,7 +166,7 @@ dozap(void) { int cnt = 1; if(!rn2(23)) cnt += rn2(7) + 1; while(cnt--) - makemon((struct permonst *) 0, u.ux, u.uy); + makemon(NULL, u.ux, u.uy); } break; case WAN_WISHING: diff --git a/games/rogue/init.c b/games/rogue/init.c index c07e82afbd..ba45b66f3c 100644 --- a/games/rogue/init.c +++ b/games/rogue/init.c @@ -54,7 +54,7 @@ #include "rogue.h" char login_name[MAX_OPT_LEN]; -char *nick_name = (char *) 0; +char *nick_name = NULL; char *rest_file = 0; boolean cant_int = 0; boolean did_int = 0; @@ -110,7 +110,7 @@ init(int argc, char *argv[]) md_heed_signals(); if (score_only) { - put_scores((object *) 0, 0); + put_scores(NULL, 0); } seed = md_gseed(); srrandom(seed); @@ -122,8 +122,8 @@ init(int argc, char *argv[]) get_wand_and_ring_materials(); make_scroll_titles(); - level_objects.next_object = (object *) 0; - level_monsters.next_monster = (object *) 0; + level_objects.next_object = NULL; + level_monsters.next_monster = NULL; player_init(); ring_stats(0); return(0); @@ -134,7 +134,7 @@ player_init(void) { object *obj; - rogue.pack.next_object = (object *) 0; + rogue.pack.next_object = NULL; obj = alloc_object(); get_food(obj, 1); diff --git a/games/rogue/inventory.c b/games/rogue/inventory.c index d339a5db20..cde3e0dd17 100644 --- a/games/rogue/inventory.c +++ b/games/rogue/inventory.c @@ -675,7 +675,7 @@ get_id_table(const object *obj) case ARMOR: return(id_armors); } - return((struct id *) 0); + return(NULL); } void diff --git a/games/rogue/monster.c b/games/rogue/monster.c index 0e150755e2..f89fede1e1 100644 --- a/games/rogue/monster.c +++ b/games/rogue/monster.c @@ -142,7 +142,7 @@ put_mons(void) n = get_rand(4, 6); for (i = 0; i < n; i++) { - monster = gr_monster((object *) 0, 0); + monster = gr_monster(NULL, 0); if ((monster->m_flags & WANDERS) && coin_toss()) { wake_up(monster); } @@ -260,7 +260,7 @@ party_monsters(int rn, int n) } } if (found) { - monster = gr_monster((object *) 0, 0); + monster = gr_monster(NULL, 0); if (!(monster->m_flags & IMITATES)) { monster->m_flags |= WAKENS; } @@ -621,7 +621,7 @@ wanderer(void) boolean found = 0; for (i = 0; ((i < 15) && (!found)); i++) { - monster = gr_monster((object *) 0, 0); + monster = gr_monster(NULL, 0); if (!(monster->m_flags & (WAKENS | WANDERS))) { free_object(monster); } else { @@ -691,7 +691,7 @@ create_monster(void) } } if (found) { - monster = gr_monster((object *) 0, 0); + monster = gr_monster(NULL, 0); put_m_at(row, col, monster); mvaddch(row, col, gmc(monster)); if (monster->m_flags & (WANDERS | WAKENS)) { diff --git a/games/rogue/move.c b/games/rogue/move.c index 757ab93ed9..b4e9050f28 100644 --- a/games/rogue/move.c +++ b/games/rogue/move.c @@ -416,7 +416,7 @@ check_hunger(boolean msg_only) return(fainted); } if (rogue.moves_left <= STARVE) { - killed_by((object *) 0, STARVATION); + killed_by(NULL, STARVATION); } switch(e_rings) { diff --git a/games/rogue/object.c b/games/rogue/object.c index 0946a3d95c..b50a0f37fd 100644 --- a/games/rogue/object.c +++ b/games/rogue/object.c @@ -55,8 +55,8 @@ object level_objects; unsigned short dungeon[DROWS][DCOLS]; short foods = 0; -object *free_list = (object *) 0; -char *fruit = (char *) 0; +object *free_list = NULL; +char *fruit = NULL; fighter rogue = { INIT_AW, /* armor, weapon */ @@ -249,7 +249,7 @@ place_at(object *obj, int row, int col) object * object_at(object *pack, short row, short col) { - object *obj = (object *) 0; + object *obj = NULL; if (dungeon[row][col] & (MONSTER | OBJECT)) { obj = pack->next_object; @@ -722,7 +722,7 @@ c_object_for_wizard(void) object *obj; char buf[80]; - if (pack_count((object *) 0) >= MAX_PACK_COUNT) { + if (pack_count(NULL) >= MAX_PACK_COUNT) { message("pack full", 0); return; } diff --git a/games/rogue/pack.c b/games/rogue/pack.c index 7d03069dd8..a3bb3723b0 100644 --- a/games/rogue/pack.c +++ b/games/rogue/pack.c @@ -111,7 +111,7 @@ pick_up(int row, int col, short *status) if (levitate) { message("you're floating in the air!", 0); - return((object *) 0); + return(NULL); } obj = object_at(&level_objects, row, col); if (!obj) { @@ -128,7 +128,7 @@ pick_up(int row, int col, short *status) if (id_scrolls[SCARE_MONSTER].id_status == UNIDENTIFIED) { id_scrolls[SCARE_MONSTER].id_status = IDENTIFIED; } - return((object *) 0); + return(NULL); } if (obj->what_is == GOLD) { rogue.gold += obj->quantity; @@ -139,7 +139,7 @@ pick_up(int row, int col, short *status) } if (pack_count(obj) >= MAX_PACK_COUNT) { message("pack too full", 1); - return((object *) 0); + return(NULL); } dungeon[row][col] &= ~(OBJECT); take_from_pack(obj, &level_objects); @@ -374,7 +374,7 @@ unwear(object *obj) if (obj) { obj->in_use_flags &= (~BEING_WORN); } - rogue.armor = (object *) 0; + rogue.armor = NULL; } void @@ -436,7 +436,7 @@ unwield(object *obj) if (obj) { obj->in_use_flags &= (~BEING_WIELDED); } - rogue.weapon = (object *) 0; + rogue.weapon = NULL; } void diff --git a/games/rogue/room.c b/games/rogue/room.c index 047472aa61..cbf5770c71 100644 --- a/games/rogue/room.c +++ b/games/rogue/room.c @@ -69,23 +69,23 @@ struct option { } options[NOPTS] = { { "Flush typeahead during battle (\"flush\"): ", - 1, (char **) 0, &flush + 1, NULL, &flush }, { "Show position only at end of run (\"jump\"): ", - 1, (char **) 0, &jump + 1, NULL, &jump }, { "Follow turnings in passageways (\"passgo\"): ", - 1, (char **) 0, &passgo + 1, NULL, &passgo }, { "Don't print skull when killed (\"noskull\" or \"notombstone\"): ", - 1, (char **) 0, &no_skull + 1, NULL, &no_skull }, { "Ask player before saying 'Okay, bye-bye!' (\"askquit\"): ", - 1, (char **) 0, &ask_quit + 1, NULL, &ask_quit }, { "Name (\"name\"): ", diff --git a/games/rogue/save.c b/games/rogue/save.c index 6934b9101c..13620b4f65 100644 --- a/games/rogue/save.c +++ b/games/rogue/save.c @@ -55,7 +55,7 @@ #include "rogue.h" short write_failed = 0; -char *save_file = (char *) 0; +char *save_file = NULL; static char save_name[80]; extern short cur_level, max_level; @@ -298,7 +298,7 @@ read_pack(object *pack, FILE *fp, boolean is_rogue) for (;;) { r_read(fp, (char *) &read_obj, sizeof(object)); if (read_obj.ichar == 0) { - pack->next_object = (object *) 0; + pack->next_object = NULL; break; } new_obj = alloc_object(); diff --git a/games/rogue/score.c b/games/rogue/score.c index 2cda7083da..e731c2632a 100644 --- a/games/rogue/score.c +++ b/games/rogue/score.c @@ -157,7 +157,7 @@ win(void) message("", 0); id_all(); sell_pack(); - put_scores((object *) 0, WIN); + put_scores(NULL, WIN); } void @@ -200,7 +200,7 @@ quit(boolean from_intrpt) clean_up(byebye_string); } check_message(); - killed_by((object *) 0, QUIT); + killed_by(NULL, QUIT); } void diff --git a/games/rogue/trap.c b/games/rogue/trap.c index 89f32dc7fb..ee110d4cea 100644 --- a/games/rogue/trap.c +++ b/games/rogue/trap.c @@ -131,7 +131,7 @@ trap_player(short row, short col) } print_stats(STAT_HP | STAT_STRENGTH); if (rogue.hp_current <= 0) { - killed_by((object *) 0, POISON_DART); + killed_by(NULL, POISON_DART); } break; case SLEEPING_GAS_TRAP: @@ -140,7 +140,7 @@ trap_player(short row, short col) break; case RUST_TRAP: message(trap_strings[(t*2)+1], 1); - rust((object *) 0); + rust(NULL); break; } } diff --git a/games/rogue/zap.c b/games/rogue/zap.c index 1b492d0956..a293b7e7c1 100644 --- a/games/rogue/zap.c +++ b/games/rogue/zap.c @@ -384,7 +384,7 @@ bounce(short ball, short dir, short row, short col, short r) damage -= get_armor_class(rogue.armor); } sprintf(buf, "the %s hits", s); - rogue_damage(damage, (object *) 0, + rogue_damage(damage, NULL, ((ball == FIRE) ? KFIRE : HYPOTHERMIA)); message(buf, 0); } diff --git a/lib/libc/rpc/clnt_dg.c b/lib/libc/rpc/clnt_dg.c index 51df8d136b..25e4db84a6 100644 --- a/lib/libc/rpc/clnt_dg.c +++ b/lib/libc/rpc/clnt_dg.c @@ -183,7 +183,7 @@ clnt_dg_create(int fd, /* open file descriptor */ int i; for (i = 0; i < dtbsize; i++) - cond_init(&dg_cv[i], 0, (void *) 0); + cond_init(&dg_cv[i], 0, NULL); } } diff --git a/lib/libc/rpc/clnt_simple.c b/lib/libc/rpc/clnt_simple.c index 5c92d0518a..7db76862ef 100644 --- a/lib/libc/rpc/clnt_simple.c +++ b/lib/libc/rpc/clnt_simple.c @@ -106,7 +106,7 @@ rpc_call(const char *host, /* host name */ char *out, /* recv/send data */ const char *nettype) /* nettype */ { - struct rpc_call_private *rcp = (struct rpc_call_private *) 0; + struct rpc_call_private *rcp = NULL; enum clnt_stat clnt_stat; struct timeval timeout, tottimeout; static thread_key_t rpc_call_key; diff --git a/lib/libc/rpc/clnt_vc.c b/lib/libc/rpc/clnt_vc.c index dddc7b9f35..8700343a66 100644 --- a/lib/libc/rpc/clnt_vc.c +++ b/lib/libc/rpc/clnt_vc.c @@ -209,7 +209,7 @@ clnt_vc_create(int fd, /* open file descriptor */ int i; for (i = 0; i < dtbsize; i++) - cond_init(&vc_cv[i], 0, (void *) 0); + cond_init(&vc_cv[i], 0, NULL); } } else assert(vc_cv != (cond_t *) NULL); diff --git a/lib/pam_module/pam_login_access/login_access.c b/lib/pam_module/pam_login_access/login_access.c index e4125abd4c..2ea59884c2 100644 --- a/lib/pam_module/pam_login_access/login_access.c +++ b/lib/pam_module/pam_login_access/login_access.c @@ -79,9 +79,9 @@ login_access(const char *user, const char *from) if (line[0] == 0) /* skip blank lines */ continue; if (!(perm = strtok(line, fs)) - || !(users = strtok((char *) 0, fs)) - || !(froms = strtok((char *) 0, fs)) - || strtok((char *) 0, fs)) { + || !(users = strtok(NULL, fs)) + || !(froms = strtok(NULL, fs)) + || strtok(NULL, fs)) { syslog(LOG_ERR, "%s: line %d: bad field count", _PATH_LOGACCESS, lineno); continue; @@ -117,7 +117,7 @@ list_match(char *list, const char *item, * the match is affected by any exceptions. */ - for (tok = strtok(list, sep); tok != 0; tok = strtok((char *) 0, sep)) { + for (tok = strtok(list, sep); tok != 0; tok = strtok(NULL, sep)) { if (strcasecmp(tok, "EXCEPT") == 0) /* EXCEPT: give up */ break; if ((match = (*match_fn)(tok, item)) != 0) /* YES */ @@ -126,9 +126,9 @@ list_match(char *list, const char *item, /* Process exceptions to matches. */ if (match != NO) { - while ((tok = strtok((char *) 0, sep)) && strcasecmp(tok, "EXCEPT")) + while ((tok = strtok(NULL, sep)) && strcasecmp(tok, "EXCEPT")) /* VOID */ ; - if (tok == 0 || list_match((char *) 0, item, match_fn) == NO) + if (tok == 0 || list_match(NULL, item, match_fn) == NO) return (match); } return (NO); @@ -176,7 +176,7 @@ user_match(const char *tok, const char *string) */ if (tok[0] == '@') { /* netgroup */ - return (netgroup_match(tok + 1, (char *) 0, string)); + return (netgroup_match(tok + 1, NULL, string)); } else if (string_match(tok, string)) { /* ALL or exact match */ return (YES); } else if ((group = getgrnam(tok)) != NULL) {/* try group membership */ @@ -205,7 +205,7 @@ from_match(const char *tok, const char *string) */ if (tok[0] == '@') { /* netgroup */ - return (netgroup_match(tok + 1, string, (char *) 0)); + return (netgroup_match(tok + 1, string, NULL)); } else if (string_match(tok, string)) { /* ALL or exact match */ return (YES); } else if (tok[0] == '.') { /* domain: match last fields */ diff --git a/libexec/bootpd/bootpd.c b/libexec/bootpd/bootpd.c index 75e106c736..22553e8047 100644 --- a/libexec/bootpd/bootpd.c +++ b/libexec/bootpd/bootpd.c @@ -389,7 +389,7 @@ main(int argc, char **argv) #ifdef TIOCNOTTY n = open(_PATH_TTY, O_RDWR); if (n >= 0) { - ioctl(n, TIOCNOTTY, (char *) 0); + ioctl(n, TIOCNOTTY, NULL); (void) close(n); } #endif /* TIOCNOTTY */ diff --git a/libexec/bootpd/bootpgw/bootpgw.c b/libexec/bootpd/bootpgw/bootpgw.c index fa923c01b9..dfb2e218ce 100644 --- a/libexec/bootpd/bootpgw/bootpgw.c +++ b/libexec/bootpd/bootpgw/bootpgw.c @@ -368,7 +368,7 @@ main(int argc, char **argv) #ifdef TIOCNOTTY n = open(_PATH_TTY, O_RDWR); if (n >= 0) { - ioctl(n, TIOCNOTTY, (char *) 0); + ioctl(n, TIOCNOTTY, NULL); (void) close(n); } #endif /* TIOCNOTTY */ diff --git a/libexec/bootpd/getif.c b/libexec/bootpd/getif.c index b5b84ec65b..d3dfe8181a 100644 --- a/libexec/bootpd/getif.c +++ b/libexec/bootpd/getif.c @@ -56,7 +56,7 @@ getif(int s, struct in_addr *addrp) /* If no address was supplied, just return NULL. */ if (!addrp) - return (struct ifreq *) 0; + return NULL; /* Get the interface config if not done already. */ if (ifconf.ifc_len == 0) { @@ -80,11 +80,11 @@ getif(int s, struct in_addr *addrp) #endif /* SVR4 */ if ((m < 0) || (ifconf.ifc_len <= 0)) { report(LOG_ERR, "ioctl SIOCGIFCONF"); - return (struct ifreq *) 0; + return NULL; } } maxmatch = 7; /* this many bits or less... */ - ifrmax = (struct ifreq *) 0;/* ... is not a valid match */ + ifrmax = NULL; /* ... is not a valid match */ p = (char *) ifreq; len = ifconf.ifc_len; while (len > 0) { diff --git a/libexec/bootpd/lookup.c b/libexec/bootpd/lookup.c index 2e196d587e..e37891b26e 100644 --- a/libexec/bootpd/lookup.c +++ b/libexec/bootpd/lookup.c @@ -49,7 +49,7 @@ lookup_hwa(char *hostname, int htype) if (ether_hostton(hostname, &ea)) { report(LOG_ERR, "no HW addr for host \"%s\"", hostname); - return (u_char *) 0; + return NULL; } return (u_char *) & ea; } @@ -60,7 +60,7 @@ lookup_hwa(char *hostname, int htype) } /* switch */ /* If the system can't do it, just return an error. */ - return (u_char *) 0; + return NULL; } diff --git a/libexec/getty/main.c b/libexec/getty/main.c index cd77f4cb81..3b0356e048 100644 --- a/libexec/getty/main.c +++ b/libexec/getty/main.c @@ -357,7 +357,7 @@ main(int argc, char **argv) limit.rlim_max = RLIM_INFINITY; limit.rlim_cur = RLIM_INFINITY; (void)setrlimit(RLIMIT_CPU, &limit); - execle(PP, "ppplogin", ttyn, (char *) 0, env); + execle(PP, "ppplogin", ttyn, NULL, env); syslog(LOG_ERR, "%s: %m", PP); exit(1); } else if (rval || AL) { @@ -396,7 +396,7 @@ main(int argc, char **argv) limit.rlim_cur = RLIM_INFINITY; (void)setrlimit(RLIMIT_CPU, &limit); execle(LO, "login", AL ? "-fp" : "-p", name, - (char *) 0, env); + NULL, env); syslog(LOG_ERR, "%s: %m", LO); exit(1); } @@ -732,7 +732,7 @@ putf(const char *cp) case 't': slash = strrchr(ttyn, '/'); - if (slash == (char *) 0) + if (slash == NULL) puts(ttyn); else puts(&slash[1]); diff --git a/libexec/rpc.rstatd/rstat_proc.c b/libexec/rpc.rstatd/rstat_proc.c index 1ecfadda5f..bc30f28482 100644 --- a/libexec/rpc.rstatd/rstat_proc.c +++ b/libexec/rpc.rstatd/rstat_proc.c @@ -245,7 +245,7 @@ updatestat() stats_all.s1.v_pswpin = vmm.v_swappgsin; stats_all.s1.v_pswpout = vmm.v_swappgsout; stats_all.s1.v_intr = vmm.v_intr; - gettimeofday(&tm, (struct timezone *) 0); + gettimeofday(&tm, NULL); stats_all.s1.v_intr -= hz*(tm.tv_sec - btm.tv_sec) + hz*(tm.tv_usec - btm.tv_usec)/1000000; stats_all.s2.v_swtch = vmm.v_swtch; @@ -286,8 +286,7 @@ updatestat() stats_all.s1.if_oerrors += ifmd.ifmd_data.ifi_oerrors; stats_all.s1.if_collisions += ifmd.ifmd_data.ifi_collisions; } - gettimeofday((struct timeval *)&stats_all.s3.curtime, - (struct timezone *) 0); + gettimeofday((struct timeval *)&stats_all.s3.curtime, NULL); alarm(1); } diff --git a/libexec/rshd/rshd.c b/libexec/rshd/rshd.c index e53d1484b4..3c7a2f7740 100644 --- a/libexec/rshd/rshd.c +++ b/libexec/rshd/rshd.c @@ -495,8 +495,8 @@ fail: if (doencrypt) { wready = writeto; if (select(nfd, &ready, - &wready, (fd_set *) 0, - (struct timeval *) 0) < 0) + &wready, NULL, + NULL) < 0) break; } else #endif diff --git a/libexec/talkd/process.c b/libexec/talkd/process.c index 17f160c00e..a6014c256e 100644 --- a/libexec/talkd/process.c +++ b/libexec/talkd/process.c @@ -169,7 +169,7 @@ do_announce(mp, rp) return; } ptr = find_request(mp); - if (ptr == (CTL_MSG *) 0) { + if (ptr == NULL) { insert_table(mp, rp); rp->answer = announce(mp, hp->h_name); return; diff --git a/libexec/telnetd/utility.c b/libexec/telnetd/utility.c index 473834d57f..9a5e5de3f6 100644 --- a/libexec/telnetd/utility.c +++ b/libexec/telnetd/utility.c @@ -404,7 +404,7 @@ putf(char *cp, char *where) #else slash = strrchr(line, '/'); #endif - if (slash == (char *) 0) + if (slash == NULL) putstr(line); else putstr(&slash[1]); diff --git a/sbin/init/init.c b/sbin/init/init.c index 0a749f1b23..dd0c449b98 100644 --- a/sbin/init/init.c +++ b/sbin/init/init.c @@ -306,7 +306,7 @@ invalid: delset(&mask, SIGABRT, SIGFPE, SIGILL, SIGSEGV, SIGBUS, SIGSYS, SIGXCPU, SIGXFSZ, SIGHUP, SIGINT, SIGTERM, SIGTSTP, SIGALRM, SIGUSR1, SIGUSR2, 0); - sigprocmask(SIG_SETMASK, &mask, (sigset_t *) 0); + sigprocmask(SIG_SETMASK, &mask, NULL); sigemptyset(&sa.sa_mask); sa.sa_flags = 0; sa.sa_handler = SIG_IGN; @@ -351,7 +351,7 @@ handle(sig_t handler, ...) sa.sa_mask = mask_everything; /* XXX SA_RESTART? */ sa.sa_flags = sig == SIGCHLD ? SA_NOCLDSTOP : 0; - sigaction(sig, &sa, (struct sigaction *) 0); + sigaction(sig, &sa, NULL); } va_end(ap); } @@ -683,7 +683,7 @@ single_user(void) * and those are reset to SIG_DFL on exec. */ sigemptyset(&mask); - sigprocmask(SIG_SETMASK, &mask, (sigset_t *) 0); + sigprocmask(SIG_SETMASK, &mask, NULL); /* * Fire off a shell. @@ -704,7 +704,7 @@ single_user(void) * We are seriously hosed. Do our best. */ emergency("can't fork single-user shell, trying again"); - while (waitpid(-1, (int *) 0, WNOHANG) > 0) + while (waitpid(-1, NULL, WNOHANG) > 0) continue; return (state_func_t) single_user; } @@ -772,7 +772,7 @@ runcom(void) argv[2] = runcom_mode == AUTOBOOT ? "autoboot" : 0; argv[3] = 0; - sigprocmask(SIG_SETMASK, &sa.sa_mask, (sigset_t *) 0); + sigprocmask(SIG_SETMASK, &sa.sa_mask, NULL); #ifdef LOGIN_CAP setprocresources(RESOURCE_RC); @@ -785,7 +785,7 @@ runcom(void) if (pid == -1) { emergency("can't fork for %s on %s: %m", _PATH_BSHELL, _PATH_RUNCOM); - while (waitpid(-1, (int *) 0, WNOHANG) > 0) + while (waitpid(-1, NULL, WNOHANG) > 0) continue; sleep(STALL_TIMEOUT); return (state_func_t) single_user; @@ -923,7 +923,7 @@ construct_argv(char *command) free(argv); return (NULL); } - while ((argv[argc++] = strk((char *) 0)) != NULL) + while ((argv[argc++] = strk(NULL)) != NULL) continue; return argv; } @@ -1109,7 +1109,7 @@ start_window_system(session_t *sp) return; sigemptyset(&mask); - sigprocmask(SIG_SETMASK, &mask, (sigset_t *) 0); + sigprocmask(SIG_SETMASK, &mask, NULL); if (setsid() < 0) emergency("setsid failed (window) %m"); @@ -1140,7 +1140,7 @@ start_getty(session_t *sp) { pid_t pid; sigset_t mask; - time_t current_time = time((time_t *) 0); + time_t current_time = time(NULL); int too_quick = 0; char term[64], *env[2]; @@ -1176,7 +1176,7 @@ start_getty(session_t *sp) } sigemptyset(&mask); - sigprocmask(SIG_SETMASK, &mask, (sigset_t *) 0); + sigprocmask(SIG_SETMASK, &mask, NULL); #ifdef LOGIN_CAP setprocresources(RESOURCE_GETTY); @@ -1233,7 +1233,7 @@ collect_child(pid_t pid) } sp->se_process = pid; - sp->se_started = time((time_t *) 0); + sp->se_started = time(NULL); add_session(sp); } @@ -1295,12 +1295,12 @@ multi_user(void) break; } sp->se_process = pid; - sp->se_started = time((time_t *) 0); + sp->se_started = time(NULL); add_session(sp); } while (!requested_transition) - if ((pid = waitpid(-1, (int *) 0, 0)) != -1) + if ((pid = waitpid(-1, NULL, 0)) != -1) collect_child(pid); return (state_func_t) requested_transition; @@ -1530,7 +1530,7 @@ runshutdown(void) argv[2] = "single"; argv[3] = 0; - sigprocmask(SIG_SETMASK, &sa.sa_mask, (sigset_t *) 0); + sigprocmask(SIG_SETMASK, &sa.sa_mask, NULL); #ifdef LOGIN_CAP setprocresources(RESOURCE_RC); @@ -1543,7 +1543,7 @@ runshutdown(void) if (pid == -1) { emergency("can't fork for %s on %s: %m", _PATH_BSHELL, _PATH_RUNDOWN); - while (waitpid(-1, (int *) 0, WNOHANG) > 0) + while (waitpid(-1, NULL, WNOHANG) > 0) continue; sleep(STALL_TIMEOUT); return -1; diff --git a/sbin/mount_portal/mount_portal.c b/sbin/mount_portal/mount_portal.c index be30d3b42a..680ee2b84b 100644 --- a/sbin/mount_portal/mount_portal.c +++ b/sbin/mount_portal/mount_portal.c @@ -79,7 +79,7 @@ sigchld(int sig) { pid_t pid; - while ((pid = waitpid((pid_t) -1, (int *) 0, WNOHANG)) > 0) + while ((pid = waitpid((pid_t) -1, NULL, WNOHANG)) > 0) ; /* wrtp - waitpid _doesn't_ return 0 when no children! */ #ifdef notdef @@ -226,7 +226,7 @@ main(int argc, char **argv) */ FD_ZERO(&fdset); FD_SET(so, &fdset); - rc = select(so+1, &fdset, (fd_set *) 0, (fd_set *) 0, (struct timeval *) 0); + rc = select(so+1, &fdset, NULL, NULL, NULL); if (rc < 0) { if (errno == EINTR) continue; diff --git a/sbin/mount_portal/pt_tcp.c b/sbin/mount_portal/pt_tcp.c index d7fb44350c..37cfc621a0 100644 --- a/sbin/mount_portal/pt_tcp.c +++ b/sbin/mount_portal/pt_tcp.c @@ -139,7 +139,7 @@ portal_tcp(struct portal_cred *pcr, char *key, char **v, int kso, int *fdp) int so; if (priv) - so = rresvport((int *) 0); + so = rresvport(NULL); else so = socket(AF_INET, SOCK_STREAM, 0); if (so < 0) { diff --git a/sys/dev/disk/ncr/ncr.c b/sys/dev/disk/ncr/ncr.c index ed86dea9cd..3ef8309d8c 100644 --- a/sys/dev/disk/ncr/ncr.c +++ b/sys/dev/disk/ncr/ncr.c @@ -5762,7 +5762,7 @@ static void ncr_int_ma (ncb_p np, u_char dstat) olen = tblp[0]; oadr = tblp[1]; } else { - tblp = (u_int32_t *) 0; + tblp = NULL; olen = READSCRIPT_OFF(vdsp_base, vdsp_off) & 0xffffff; }; diff --git a/sys/dev/disk/sym/sym_hipd.c b/sys/dev/disk/sym/sym_hipd.c index 768ae2661f..6d1be2641d 100644 --- a/sys/dev/disk/sym/sym_hipd.c +++ b/sys/dev/disk/sym/sym_hipd.c @@ -4521,7 +4521,7 @@ static void sym_int_ma (hcb_p np) olen = scr_to_cpu(tblp[0]); oadr = scr_to_cpu(tblp[1]); } else { - tblp = (u32 *) 0; + tblp = NULL; olen = scr_to_cpu(vdsp[0]) & 0xffffff; }; diff --git a/sys/dev/netif/ie/if_ie.c b/sys/dev/netif/ie/if_ie.c index fb0d1b5077..67e013e43e 100644 --- a/sys/dev/netif/ie/if_ie.c +++ b/sys/dev/netif/ie/if_ie.c @@ -2141,7 +2141,7 @@ ie_mc_reset(int unit) /* XXX - this is broken... */ if (ie->mcast_count >= MAXMCAST) { ie->arpcom.ac_if.if_flags |= IFF_ALLMULTI; - ieioctl(&ie->arpcom.ac_if, SIOCSIFFLAGS, (void *) 0, + ieioctl(&ie->arpcom.ac_if, SIOCSIFFLAGS, NULL, (struct ucred *)NULL); goto setflag; } diff --git a/sys/dev/netif/wl/if_wl.c b/sys/dev/netif/wl/if_wl.c index cbb00f1ad6..4c8eaa4a57 100644 --- a/sys/dev/netif/wl/if_wl.c +++ b/sys/dev/netif/wl/if_wl.c @@ -1097,7 +1097,7 @@ wlread(struct wl_softc *sc, u_short fd_p) } return 0; } - m->m_next = (struct mbuf *) 0; + m->m_next = NULL; m->m_pkthdr.rcvif = ifp; m->m_pkthdr.len = 0; /* don't know this yet */ m->m_len = MHLEN; @@ -1861,7 +1861,7 @@ wlxmt(struct wl_softc *sc, struct mbuf *m) continue; } /* next mbuf short -> coallesce as needed */ - if ( (tm_p->m_next == (struct mbuf *) 0) || + if ( (tm_p->m_next == NULL) || #define HDW_THRESHOLD 55 tm_p->m_len > HDW_THRESHOLD) /* ok */; diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c index 7179b26447..7e844cf107 100644 --- a/sys/netinet/igmp.c +++ b/sys/netinet/igmp.c @@ -117,7 +117,7 @@ igmp_init(void) ra->ipopt_list[3] = 0x00; router_alert->m_len = sizeof(ra->ipopt_dst) + ra->ipopt_list[1]; - Head = (struct router_info *) 0; + Head = NULL; } static struct router_info * diff --git a/sys/netproto/atalk/at_control.c b/sys/netproto/atalk/at_control.c index 70d55cd0ad..007924fd7d 100644 --- a/sys/netproto/atalk/at_control.c +++ b/sys/netproto/atalk/at_control.c @@ -140,7 +140,7 @@ at_control(struct socket *so, u_long cmd, caddr_t data, * If we failed to find an existing at_ifaddr entry, then we * allocate a fresh one. */ - if ( aa == (struct at_ifaddr *) 0 ) { + if ( aa == NULL ) { aa0 = ifa_create(sizeof(struct at_ifaddr), M_WAITOK); callout_init(&aa0->aa_ch); if (( aa = at_ifaddr ) != NULL ) { @@ -226,7 +226,7 @@ at_control(struct socket *so, u_long cmd, caddr_t data, } } - if ( aa == (struct at_ifaddr *) 0 ) + if ( aa == NULL ) return( EADDRNOTAVAIL ); break; } diff --git a/sys/netproto/atm/spans/spans_print.c b/sys/netproto/atm/spans/spans_print.c index b39ad7f7e6..33897b55c0 100644 --- a/sys/netproto/atm/spans/spans_print.c +++ b/sys/netproto/atm/spans/spans_print.c @@ -207,7 +207,7 @@ spans_msgtype_str(spans_msgtype *objp, char *dest, int len) { SPANS_VCIR_IND, "SPANS_VCIR_IND" }, { SPANS_QUERY_REQ, "SPANS_QUERY_REQ" }, { SPANS_QUERY_RSP, "SPANS_QUERY_RSP" }, - { 0, (char *) 0 } + { 0, NULL } }; /* diff --git a/sys/netproto/atm/uni/unisig_decode.c b/sys/netproto/atm/uni/unisig_decode.c index 010586ed3a..743f113f6e 100644 --- a/sys/netproto/atm/uni/unisig_decode.c +++ b/sys/netproto/atm/uni/unisig_decode.c @@ -859,8 +859,7 @@ usf_dec_msg(struct usfmt *usf, struct unisig_msg *msg) * Disallowed IE present */ ie = msg->msg_ie_vec[i]; - msg->msg_ie_vec[i] = - (struct ie_generic *) 0; + msg->msg_ie_vec[i] = NULL; MSG_IE_ADD(msg, ie, UNI_MSG_IE_ERR); while (ie) { ie->ie_err_cause = diff --git a/sys/netproto/atm/uni/unisig_if.c b/sys/netproto/atm/uni/unisig_if.c index d177075f92..d304895dcb 100644 --- a/sys/netproto/atm/uni/unisig_if.c +++ b/sys/netproto/atm/uni/unisig_if.c @@ -557,8 +557,7 @@ unisig_accept(struct vccb *vcp, int *errp) /* * Pass the acceptance to the VC state machine */ - *errp = unisig_vc_state(usp, uvp, UNI_VC_ACCEPT_CALL, - (struct unisig_msg *) 0); + *errp = unisig_vc_state(usp, uvp, UNI_VC_ACCEPT_CALL, NULL); if (*errp) goto failed; @@ -622,8 +621,7 @@ unisig_reject(struct vccb *vcp, int *errp) /* * Call the VC state machine */ - *errp = unisig_vc_state(usp, uvp, UNI_VC_REJECT_CALL, - (struct unisig_msg *) 0); + *errp = unisig_vc_state(usp, uvp, UNI_VC_REJECT_CALL, NULL); if (*errp) goto failed; diff --git a/sys/netproto/atm/uni/unisig_msg.c b/sys/netproto/atm/uni/unisig_msg.c index 0995a5044e..1b16424084 100644 --- a/sys/netproto/atm/uni/unisig_msg.c +++ b/sys/netproto/atm/uni/unisig_msg.c @@ -190,7 +190,7 @@ unisig_send_msg(struct unisig *usp, struct unisig_msg *msg) /* * Convert message to network order */ - err = usf_init(&usf, usp, (KBuffer *) 0, USF_ENCODE, + err = usf_init(&usf, usp, NULL, USF_ENCODE, usp->us_headout); if (err) return(err); @@ -843,7 +843,7 @@ unisig_rcv_msg(struct unisig *usp, KBuffer *m) /* * Send STATUS message indicating the error */ - err = unisig_send_status(usp, (struct unisig_vccb *) 0, + err = unisig_send_status(usp, NULL, msg, UNI_IE_CAUS_CREF); goto done; } diff --git a/sys/netproto/atm/uni/unisig_proto.c b/sys/netproto/atm/uni/unisig_proto.c index ab5d17e809..17d552c25a 100644 --- a/sys/netproto/atm/uni/unisig_proto.c +++ b/sys/netproto/atm/uni/unisig_proto.c @@ -74,7 +74,7 @@ unisig_timer(struct atm_time *tip) */ unisig_sigmgr_state(usp, UNISIG_SIGMGR_TIMEOUT, - (KBuffer *) 0); + NULL); } @@ -117,13 +117,13 @@ unisig_vctimer(struct atm_time *tip) * If we're aborting, this is an ABORT call */ unisig_vc_state(usp, uvp, UNI_VC_ABORT_CALL, - (struct unisig_msg *) 0); + NULL); } else { /* * If we're not aborting, it's a timeout */ unisig_vc_state(usp, uvp, UNI_VC_TIMEOUT, - (struct unisig_msg *) 0); + NULL); } } @@ -160,25 +160,25 @@ unisig_saal_ctl(int cmd, void *tok, void *a1) case SSCF_UNI_ESTABLISH_IND: unisig_sigmgr_state(usp, UNISIG_SIGMGR_SSCF_EST_IND, - (KBuffer *) 0); + NULL); break; case SSCF_UNI_ESTABLISH_CNF: unisig_sigmgr_state(usp, UNISIG_SIGMGR_SSCF_EST_CNF, - (KBuffer *) 0); + NULL); break; case SSCF_UNI_RELEASE_IND: unisig_sigmgr_state(usp, UNISIG_SIGMGR_SSCF_RLS_IND, - (KBuffer *) 0); + NULL); break; case SSCF_UNI_RELEASE_CNF: unisig_sigmgr_state(usp, UNISIG_SIGMGR_SSCF_RLS_CNF, - (KBuffer *) 0); + NULL); break; default: @@ -301,5 +301,5 @@ unisig_cleared(void *tok, struct t_atm_cause *cp) */ unisig_sigmgr_state(usp, UNISIG_SIGMGR_CALL_CLEARED, - (KBuffer *) 0); + NULL); } diff --git a/sys/netproto/atm/uni/unisig_sigmgr_state.c b/sys/netproto/atm/uni/unisig_sigmgr_state.c index d578058cd0..5198b39470 100644 --- a/sys/netproto/atm/uni/unisig_sigmgr_state.c +++ b/sys/netproto/atm/uni/unisig_sigmgr_state.c @@ -365,7 +365,7 @@ unisig_sigmgr_act03(struct unisig *usp, KBuffer *m) uvp; uvp = vnext) { vnext = Q_NEXT(uvp, struct unisig_vccb, uv_sigelem); unisig_vc_state(usp, uvp, UNI_VC_SAAL_ESTAB, - (struct unisig_msg *) 0); + NULL); } return(0); @@ -434,7 +434,7 @@ unisig_sigmgr_act05(struct unisig *usp, KBuffer *m) uvp; uvp = vnext) { vnext = Q_NEXT(uvp, struct unisig_vccb, uv_sigelem); unisig_vc_state(usp, uvp, UNI_VC_SAAL_ESTAB, - (struct unisig_msg *) 0); + NULL); } return(0); @@ -472,13 +472,13 @@ unisig_sigmgr_act06(struct unisig *usp, KBuffer *m) uvp; uvp = vnext) { vnext = Q_NEXT(uvp, struct unisig_vccb, uv_sigelem); unisig_vc_state(usp, uvp, UNI_VC_SAAL_FAIL, - (struct unisig_msg *) 0); + NULL); } /* * Try to restart the SSCF session */ - unisig_sigmgr_act04(usp, (KBuffer *) 0); + unisig_sigmgr_act04(usp, NULL); /* * Go to INIT state diff --git a/sys/netproto/atm/uni/unisig_subr.c b/sys/netproto/atm/uni/unisig_subr.c index 45823932f8..9fe0109be5 100644 --- a/sys/netproto/atm/uni/unisig_subr.c +++ b/sys/netproto/atm/uni/unisig_subr.c @@ -280,8 +280,7 @@ unisig_open_vcc(struct unisig *usp, Atm_connvc *cvp) * Call the VC state machine if this is an SVC */ if (!pvc) { - err = unisig_vc_state(usp, uvp, UNI_VC_SETUP_CALL, - (struct unisig_msg *) 0); + err = unisig_vc_state(usp, uvp, UNI_VC_SETUP_CALL, NULL); if (err) { /* * On error, delete the VCCB @@ -349,8 +348,7 @@ unisig_close_vcc(struct unisig *usp, struct unisig_vccb *uvp) * Call the VC state machine */ uvp->uv_ustate = VCCU_CLOSED; - err = unisig_vc_state(usp, uvp, UNI_VC_RELEASE_CALL, - (struct unisig_msg *) 0); + err = unisig_vc_state(usp, uvp, UNI_VC_RELEASE_CALL, NULL); } /* diff --git a/sys/netproto/ns/spp_usrreq.c b/sys/netproto/ns/spp_usrreq.c index 5539cd8475..f95040bbb3 100644 --- a/sys/netproto/ns/spp_usrreq.c +++ b/sys/netproto/ns/spp_usrreq.c @@ -1511,7 +1511,7 @@ spp_rcvd(struct socket *so, int flags) if (nsp) { cb = nstosppcb(nsp); cb->s_flags |= SF_RVD; - spp_output(cb, (struct mbuf *) 0); + spp_output(cb, NULL); cb->s_flags &= ~SF_RVD; error = 0; } else { @@ -1792,7 +1792,7 @@ spp_fasttimo(void) cb->s_flags &= ~SF_DELACK; cb->s_flags |= SF_ACKNOW; sppstat.spps_delack++; - spp_output(cb, (struct mbuf *) 0); + spp_output(cb, NULL); } } } @@ -1904,7 +1904,7 @@ spp_timers(struct sppcb *cb, int timer) win = 2; cb->s_cwnd = CUNIT; cb->s_ssthresh = win * CUNIT; - spp_output(cb, (struct mbuf *) 0); + spp_output(cb, NULL); break; /* @@ -1914,7 +1914,7 @@ spp_timers(struct sppcb *cb, int timer) case SPPT_PERSIST: sppstat.spps_persisttimeo++; spp_setpersist(cb); - spp_output(cb, (struct mbuf *) 0); + spp_output(cb, NULL); break; /* @@ -1929,7 +1929,7 @@ spp_timers(struct sppcb *cb, int timer) if (cb->s_idle >= SPPTV_MAXIDLE) goto dropit; sppstat.spps_keepprobe++; - spp_output(cb, (struct mbuf *) 0); + spp_output(cb, NULL); } else cb->s_idle = 0; cb->s_timer[SPPT_KEEP] = SPPTV_KEEP; diff --git a/sys/opencrypto/xform.c b/sys/opencrypto/xform.c index e4b106d624..6201dca219 100644 --- a/sys/opencrypto/xform.c +++ b/sys/opencrypto/xform.c @@ -549,7 +549,7 @@ null_update(void *ctx, u_int8_t *buf, u_int16_t len) static void null_final(u_int8_t *buf, void *ctx) { - if (buf != (u_int8_t *) 0) + if (buf != NULL) bzero(buf, 12); } diff --git a/sys/vfs/portal/portal_vfsops.c b/sys/vfs/portal/portal_vfsops.c index a34c1ec7dc..2d4603f21e 100644 --- a/sys/vfs/portal/portal_vfsops.c +++ b/sys/vfs/portal/portal_vfsops.c @@ -184,7 +184,7 @@ portal_unmount(struct mount *mp, int mntflags) * Discard reference to underlying file. Must call closef because * this may be the last reference. */ - closef(VFSTOPORTAL(mp)->pm_server, (struct thread *) 0); + closef(VFSTOPORTAL(mp)->pm_server, NULL); /* * Finally, throw away the portalmount structure */ diff --git a/sys/vfs/portal/portal_vnops.c b/sys/vfs/portal/portal_vnops.c index e6cea3faa4..2425f6ac14 100644 --- a/sys/vfs/portal/portal_vnops.c +++ b/sys/vfs/portal/portal_vnops.c @@ -318,8 +318,7 @@ portal_open(struct vop_open_args *ap) auio.uio_offset = 0; auio.uio_resid = aiov[0].iov_len + aiov[1].iov_len; - error = sosend(so, (struct sockaddr *) 0, &auio, - (struct mbuf *) 0, (struct mbuf *) 0, 0, td); + error = sosend(so, NULL, &auio, NULL, NULL, 0, td); if (error) goto bad; diff --git a/test/stress/fsx/fsx.c b/test/stress/fsx/fsx.c index 64c63df0c5..89bb9e6219 100644 --- a/test/stress/fsx/fsx.c +++ b/test/stress/fsx/fsx.c @@ -913,7 +913,7 @@ getnum(char *s, char **e) { int ret = -1; - *e = (char *) 0; + *e = NULL; ret = strtol(s, e, 0); if (*e) switch (**e) { diff --git a/tools/regression/fsx/fsx.c b/tools/regression/fsx/fsx.c index b75a3117e9..b75047bf4e 100644 --- a/tools/regression/fsx/fsx.c +++ b/tools/regression/fsx/fsx.c @@ -891,7 +891,7 @@ getnum(char *s, char **e) { int ret = -1; - *e = (char *) 0; + *e = NULL; ret = strtol(s, e, 0); if (*e) switch (**e) { diff --git a/usr.bin/chat/chat.c b/usr.bin/chat/chat.c index 4cc0502e59..dac1234150 100644 --- a/usr.bin/chat/chat.c +++ b/usr.bin/chat/chat.c @@ -116,11 +116,11 @@ int to_stderr = 0; int Verbose = 0; int quiet = 0; int exit_code = 0; -FILE* report_fp = (FILE *) 0; -char *report_file = (char *) 0; -char *chat_file = (char *) 0; -char *phone_num = (char *) 0; -char *phone_num2 = (char *) 0; +FILE* report_fp = NULL; +char *report_file = NULL; +char *chat_file = NULL; +char *phone_num = NULL; +char *phone_num2 = NULL; int timeout = DEFAULT_CHAT_TIMEOUT; static char blank[] = ""; @@ -511,7 +511,7 @@ void break_sequence(void) void terminate(int status) { echo_stderr(-1); - if (report_file != (char *) 0 && report_fp != (FILE *) NULL) { + if (report_file != NULL && report_fp != (FILE *) NULL) { /* * Allow the last of the report string to be gathered before we terminate. */ @@ -721,7 +721,7 @@ expect_strtok (char *s, const char *term) if (*str) result = str; else - result = (char *) 0; + result = NULL; while (*str) { if (escape_flag) { @@ -739,7 +739,7 @@ expect_strtok (char *s, const char *term) /* * If this is not in the termination string, continue. */ - if (strchr (term, *str) == (char *) 0) { + if (strchr (term, *str) == NULL) { ++str; continue; } @@ -808,9 +808,9 @@ chat_expect(char *s) */ for (;;) { expect = expect_strtok (s, "-"); - s = (char *) 0; + s = NULL; - if (expect == (char *) 0) + if (expect == NULL) return; reply = expect_strtok (s, "-"); @@ -825,7 +825,7 @@ chat_expect(char *s) * If there is a sub-reply string then send it. Otherwise any condition * is terminal. */ - if (reply == (char *) 0 || exit_code != 3) + if (reply == NULL || exit_code != 3) break; chat_send (reply); diff --git a/usr.bin/ee/ee.c b/usr.bin/ee/ee.c index 294bf86996..0bf023e9ce 100644 --- a/usr.bin/ee/ee.c +++ b/usr.bin/ee/ee.c @@ -3145,7 +3145,7 @@ sh_command(char *string) /* execute shell command */ } do { - return_val = wait((int *) 0); + return_val = wait(NULL); } while ((return_val != parent) && (return_val != -1)); /* diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c index b5d79c7e9a..f5bbaa5d12 100644 --- a/usr.bin/find/function.c +++ b/usr.bin/find/function.c @@ -1028,7 +1028,7 @@ c_newer(OPTION *option, char ***argvp) new = palloc(option); /* compare against what */ if (option->flags & F_TIME2_T) { - new->t_data = get_date(fn_or_tspec, (struct timeb *) 0); + new->t_data = get_date(fn_or_tspec, NULL); if (new->t_data == (time_t) -1) errx(1, "Can't parse date/time: %s", fn_or_tspec); } else { diff --git a/usr.bin/gprof/arcs.c b/usr.bin/gprof/arcs.c index b964fec735..efb9856a2a 100644 --- a/usr.bin/gprof/arcs.c +++ b/usr.bin/gprof/arcs.c @@ -193,7 +193,7 @@ doarcs(void) * Sort the symbol table in reverse topological order */ topsortnlp = (nltype **) calloc( nname , sizeof(nltype *) ); - if ( topsortnlp == (nltype **) 0 ) { + if ( topsortnlp == NULL ) { fprintf( stderr , "[doarcs] ran out of memory for topo sorting\n" ); } for ( index = 0 ; index < nname ; index += 1 ) { @@ -230,7 +230,7 @@ doarcs(void) * and cycle headers. */ timesortnlp = (nltype **) calloc( nname + ncycle , sizeof(nltype *) ); - if ( timesortnlp == (nltype **) 0 ) { + if ( timesortnlp == NULL ) { warnx("ran out of memory for sorting"); } for ( index = 0 ; index < nname ; index++ ) { diff --git a/usr.bin/gprof/printgprof.c b/usr.bin/gprof/printgprof.c index 5985eb3ca7..65a9a76b97 100644 --- a/usr.bin/gprof/printgprof.c +++ b/usr.bin/gprof/printgprof.c @@ -52,7 +52,7 @@ printprof(void) * Sort the symbol table in by time */ sortednlp = (nltype **) calloc( nname , sizeof(nltype *) ); - if ( sortednlp == (nltype **) 0 ) { + if ( sortednlp == NULL ) { fprintf( stderr , "[printprof] ran out of memory for time sorting\n" ); } for ( index = 0 ; index < nname ; index += 1 ) { @@ -678,7 +678,7 @@ printindex(void) * to create an index. */ namesortnlp = (nltype **) calloc( nname + ncycle , sizeof(nltype *) ); - if ( namesortnlp == (nltype **) 0 ) { + if ( namesortnlp == NULL ) { warnx("ran out of memory for sorting"); } for ( index = 0 , nnames = 0 ; index < nname ; index++ ) { diff --git a/usr.bin/gprof/printlist.c b/usr.bin/gprof/printlist.c index d16608d035..35f7746227 100644 --- a/usr.bin/gprof/printlist.c +++ b/usr.bin/gprof/printlist.c @@ -62,7 +62,7 @@ addlist(struct stringlist *listp, char *funcname) struct stringlist *slp; slp = (struct stringlist *) malloc( sizeof(struct stringlist)); - if ( slp == (struct stringlist *) 0 ) { + if ( slp == NULL ) { warnx("ran out room for printlist"); done(); } diff --git a/usr.bin/gprof/sparc.c b/usr.bin/gprof/sparc.c index 3b720b2ece..2384c694f8 100644 --- a/usr.bin/gprof/sparc.c +++ b/usr.bin/gprof/sparc.c @@ -63,9 +63,9 @@ nltype indirectchild = { (int) 0 , /* internal number of cycle on */ (int) 0 , /* number of live parent arcs */ (struct nl *) &indirectchild , /* pointer to head of cycle */ - (struct nl *) 0 , /* pointer to next member of cycle */ - (arctype *) 0 , /* list of caller arcs */ - (arctype *) 0 /* list of callee arcs */ + NULL , /* pointer to next member of cycle */ + NULL , /* list of caller arcs */ + NULL /* list of callee arcs */ }; findcall(nltype *parentp, unsigned long p_lowpc, unsigned long p_highpc) diff --git a/usr.bin/lex/dfa.c b/usr.bin/lex/dfa.c index 866d0a0b5b..c942832010 100644 --- a/usr.bin/lex/dfa.c +++ b/usr.bin/lex/dfa.c @@ -851,7 +851,7 @@ int snstods(int *sns, int numstates, int *accset, int nacc, int hashval, if ( nacc == 0 ) { if ( reject ) - dfaacc[newds].dfaacc_set = (int *) 0; + dfaacc[newds].dfaacc_set = NULL; else dfaacc[newds].dfaacc_state = 0; diff --git a/usr.bin/lex/flex.skl b/usr.bin/lex/flex.skl index dca7ee513d..aff70d8e6b 100644 --- a/usr.bin/lex/flex.skl +++ b/usr.bin/lex/flex.skl @@ -226,7 +226,7 @@ static int yy_n_chars; /* number of characters read into yy_ch_buf */ int yyleng; /* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; +static char *yy_c_buf_p = NULL; static int yy_init = 1; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ diff --git a/usr.bin/lex/initscan.c b/usr.bin/lex/initscan.c index 6e225edd36..b792d834a5 100644 --- a/usr.bin/lex/initscan.c +++ b/usr.bin/lex/initscan.c @@ -210,7 +210,7 @@ static int yy_n_chars; /* number of characters read into yy_ch_buf */ int yyleng; /* Points to current character in buffer. */ -static char *yy_c_buf_p = (char *) 0; +static char *yy_c_buf_p = NULL; static int yy_init = 1; /* whether we need to initialize */ static int yy_start = 0; /* start state number */ @@ -256,7 +256,7 @@ static void yy_flex_free YY_PROTO(( void * )); #define YY_AT_BOL() (yy_current_buffer->yy_at_bol) typedef unsigned char YY_CHAR; -FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0; +FILE *yyin = NULL, *yyout = NULL; typedef int yy_state_type; extern char *yytext; #define yytext_ptr yytext @@ -1602,7 +1602,7 @@ YY_RULE_SETUP #line 110 "scan.l" { ++linenum; - line_directive_out( (FILE *) 0, 1 ); + line_directive_out( NULL, 1 ); indented_code = false; BEGIN(CODEBLOCK); } @@ -1619,7 +1619,7 @@ YY_RULE_SETUP sectnum = 2; bracelevel = 0; mark_defs1(); - line_directive_out( (FILE *) 0, 1 ); + line_directive_out( NULL, 1 ); BEGIN(SECT2PROLOG); return SECTEND; } diff --git a/usr.bin/lex/main.c b/usr.bin/lex/main.c index ab41f59e68..18933c596a 100644 --- a/usr.bin/lex/main.c +++ b/usr.bin/lex/main.c @@ -835,9 +835,9 @@ void readin(void) { static char yy_stdinit[] = "FILE *yyin = stdin, *yyout = stdout;"; static char yy_nostdinit[] = - "FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;"; + "FILE *yyin = NULL, *yyout = NULL;"; - line_directive_out( (FILE *) 0, 1 ); + line_directive_out( NULL, 1 ); if ( yyparse() ) { @@ -1079,7 +1079,7 @@ void set_up_initial_allocations(void) dss = allocate_int_ptr_array( current_max_dfas ); dfaacc = allocate_dfaacc_union( current_max_dfas ); - nultrans = (int *) 0; + nultrans = NULL; } diff --git a/usr.bin/lex/nfa.c b/usr.bin/lex/nfa.c index 181ca778fa..5fe9f7ea81 100644 --- a/usr.bin/lex/nfa.c +++ b/usr.bin/lex/nfa.c @@ -266,7 +266,7 @@ void finish_rule(int mach, int variable_trail_rule, int headcnt, int trailcnt) if ( ! continued_action ) add_action( "YY_RULE_SETUP\n" ); - line_directive_out( (FILE *) 0, 1 ); + line_directive_out( NULL, 1 ); } diff --git a/usr.bin/lex/parse.y b/usr.bin/lex/parse.y index 46fb0c1a2a..3eacfa2a47 100644 --- a/usr.bin/lex/parse.y +++ b/usr.bin/lex/parse.y @@ -788,7 +788,7 @@ void build_eof_action( void ) } } - line_directive_out( (FILE *) 0, 1 ); + line_directive_out( NULL, 1 ); /* This isn't a normal rule after all - don't count it as * such, so we don't have any holes in the rule numbering diff --git a/usr.bin/lex/scan.l b/usr.bin/lex/scan.l index ce9fdfd647..e481905539 100644 --- a/usr.bin/lex/scan.l +++ b/usr.bin/lex/scan.l @@ -111,7 +111,7 @@ LEXOPT [aceknopr] ^"%x"{NAME}? return XSCDECL; ^"%{".*{NL} { ++linenum; - line_directive_out( (FILE *) 0, 1 ); + line_directive_out( NULL, 1 ); indented_code = false; BEGIN(CODEBLOCK); } @@ -122,7 +122,7 @@ LEXOPT [aceknopr] sectnum = 2; bracelevel = 0; mark_defs1(); - line_directive_out( (FILE *) 0, 1 ); + line_directive_out( NULL, 1 ); BEGIN(SECT2PROLOG); return SECTEND; } diff --git a/usr.bin/lex/sym.c b/usr.bin/lex/sym.c index 4d92ff902f..7b1996de48 100644 --- a/usr.bin/lex/sym.c +++ b/usr.bin/lex/sym.c @@ -104,7 +104,7 @@ void cclinstal(Char *ccltxt, int cclnum) Char *copy_unsigned_string(); (void) addsym( (char *) copy_unsigned_string( ccltxt ), - (char *) 0, cclnum, + NULL, cclnum, ccltab, CCL_HASH_SIZE ); } @@ -126,8 +126,8 @@ struct hash_entry *findsym(char *sym, hash_table table, int table_size) { static struct hash_entry empty_entry = { - (struct hash_entry *) 0, (struct hash_entry *) 0, - (char *) 0, (char *) 0, 0, + NULL, NULL, + NULL, NULL, 0, } ; struct hash_entry *sym_entry = table[hashfunct( sym, table_size )]; @@ -222,7 +222,7 @@ void scinstal(char *str, int xcluflg) scname[lastsc] = copy_string( str ); - if ( addsym( scname[lastsc], (char *) 0, lastsc, + if ( addsym( scname[lastsc], NULL, lastsc, sctbl, START_COND_HASH_SIZE ) ) format_pinpoint_message( _( "start condition %s declared twice" ), diff --git a/usr.bin/login/login_fbtab.c b/usr.bin/login/login_fbtab.c index c235cfef08..04aa4e05d4 100644 --- a/usr.bin/login/login_fbtab.c +++ b/usr.bin/login/login_fbtab.c @@ -99,17 +99,17 @@ login_fbtab(char *tty, uid_t uid, gid_t gid) if ((cp = devname = strtok(buf, WSPACE)) == 0) continue; /* empty or comment */ if (strncmp(devname, _PATH_DEV, sizeof _PATH_DEV - 1) != 0 - || (cp = strtok((char *) 0, WSPACE)) == 0 + || (cp = strtok(NULL, WSPACE)) == 0 || *cp != '0' || sscanf(cp, "%o", &prot) == 0 || prot == 0 || (prot & 0777) != prot - || (cp = strtok((char *) 0, WSPACE)) == 0) { + || (cp = strtok(NULL, WSPACE)) == 0) { syslog(LOG_ERR, "%s: bad entry: %s", table, cp ? cp : "(null)"); continue; } if (strcmp(devname + 5, tty) == 0) { - for (cp = strtok(cp, ":"); cp; cp = strtok((char *) 0, ":")) { + for (cp = strtok(cp, ":"); cp; cp = strtok(NULL, ":")) { login_protect(table, cp, prot, uid, gid); } } diff --git a/usr.bin/systat/cmds.c b/usr.bin/systat/cmds.c index 66531d245a..560956612c 100644 --- a/usr.bin/systat/cmds.c +++ b/usr.bin/systat/cmds.c @@ -150,7 +150,7 @@ lookup(const char *name) longest = 0; nmatches = 0; - found = (struct cmdtab *) 0; + found = NULL; for (ct = cmdtab; (p = ct->c_name); ct++) { for (q = name; *q == *p++; q++) if (*q == 0) /* exact match? */ diff --git a/usr.bin/telnet/sys_bsd.c b/usr.bin/telnet/sys_bsd.c index f05fb1058f..cce0b0b5bc 100644 --- a/usr.bin/telnet/sys_bsd.c +++ b/usr.bin/telnet/sys_bsd.c @@ -220,9 +220,9 @@ void TerminalFlushOutput(void) { #ifdef TIOCFLUSH - (void) ioctl(fileno(stdout), TIOCFLUSH, (char *) 0); + (void) ioctl(fileno(stdout), TIOCFLUSH, NULL); #else - (void) ioctl(fileno(stdout), TCFLSH, (char *) 0); + (void) ioctl(fileno(stdout), TCFLSH, NULL); #endif } diff --git a/usr.bin/telnet/utilities.c b/usr.bin/telnet/utilities.c index 36be9a2efe..885c8b920d 100644 --- a/usr.bin/telnet/utilities.c +++ b/usr.bin/telnet/utilities.c @@ -719,14 +719,12 @@ EmptyTerminal(void) if (TTYBYTES() == 0) { FD_SET(tout, &o); - (void) select(tout+1, (fd_set *) 0, &o, (fd_set *) 0, - (struct timeval *) 0); /* wait for TTLOWAT */ + (void) select(tout+1, NULL, &o, NULL, NULL); /* wait for TTLOWAT */ } else { while (TTYBYTES()) { (void) ttyflush(0); FD_SET(tout, &o); - (void) select(tout+1, (fd_set *) 0, &o, (fd_set *) 0, - (struct timeval *) 0); /* wait for TTLOWAT */ + (void) select(tout+1, NULL, &o, NULL, NULL); /* wait for TTLOWAT */ } } } diff --git a/usr.bin/window/cmd1.c b/usr.bin/window/cmd1.c index 0afd6d4f03..345ee445a6 100644 --- a/usr.bin/window/cmd1.c +++ b/usr.bin/window/cmd1.c @@ -105,7 +105,7 @@ c_window() wwputc('\n', cmdwin); wwcurtowin(cmdwin); (void) openwin(id, row, col, xrow-row+1, xcol-col+1, default_nline, - (char *) 0, 1, 1, default_shellfile, default_shell); + NULL, 1, 1, default_shellfile, default_shell); } getpos(row, col, minrow, mincol, maxrow, maxcol) diff --git a/usr.bin/window/startup.c b/usr.bin/window/startup.c index 0450c81a92..1d5dee6c80 100644 --- a/usr.bin/window/startup.c +++ b/usr.bin/window/startup.c @@ -69,10 +69,10 @@ dodefault() register r = wwnrow / 2 - 1; if (openwin(1, r + 2, 0, wwnrow - r - 2, wwncol, default_nline, - (char *) 0, 1, 1, default_shellfile, default_shell) == 0) + NULL, 1, 1, default_shellfile, default_shell) == 0) return; if ((w = openwin(0, 1, 0, r, wwncol, default_nline, - (char *) 0, 1, 1, default_shellfile, default_shell)) == 0) + NULL, 1, 1, default_shellfile, default_shell)) == 0) return; wwprintf(w, "Escape character is %s.\r\n", unctrl(escapec)); } diff --git a/usr.sbin/inetd/builtins.c b/usr.sbin/inetd/builtins.c index 15f9c3073c..0b56967fa9 100644 --- a/usr.sbin/inetd/builtins.c +++ b/usr.sbin/inetd/builtins.c @@ -199,7 +199,7 @@ daytime_dg(int s, struct servtab *sep) /* Return human-readable time of day */ struct sockaddr_storage ss; socklen_t size; - now = time((time_t *) 0); + now = time(NULL); size = sizeof(ss); if (recvfrom(s, buffer, sizeof(buffer), 0, @@ -220,7 +220,7 @@ daytime_stream(int s, struct servtab *sep __unused) /* Return human-readable tim char buffer[256]; time_t now; - now = time((time_t *) 0); + now = time(NULL); sprintf(buffer, "%.24s\r\n", ctime(&now)); send(s, buffer, strlen(buffer), MSG_EOF); diff --git a/usr.sbin/mrouted/callout.c b/usr.sbin/mrouted/callout.c index 5daff27e86..80448239fb 100644 --- a/usr.sbin/mrouted/callout.c +++ b/usr.sbin/mrouted/callout.c @@ -36,7 +36,7 @@ static void print_Q(void); void callout_init(void) { - Q = (struct timeout_q *) 0; + Q = NULL; } void diff --git a/usr.sbin/mrouted/mtrace.c b/usr.sbin/mrouted/mtrace.c index b096d0a6d4..632c4f6036 100644 --- a/usr.sbin/mrouted/mtrace.c +++ b/usr.sbin/mrouted/mtrace.c @@ -2355,7 +2355,7 @@ main(int argc, char **argv) p++; do { char c = *p++; - char *arg = (char *) 0; + char *arg = NULL; if (isdigit(*p)) { arg = p; p = ""; diff --git a/usr.sbin/pciconf/pciconf.c b/usr.sbin/pciconf/pciconf.c index 901bbc029c..32a4f7117e 100644 --- a/usr.sbin/pciconf/pciconf.c +++ b/usr.sbin/pciconf/pciconf.c @@ -510,7 +510,7 @@ readit(const char *name, const char *reg, int width) rend = rstart = strtol(reg, &end, 0); if (end && *end == ':') { end++; - rend = strtol(end, (char **) 0, 0); + rend = strtol(end, NULL, 0); } sel = getsel(name); for (i = 1, r = rstart; r <= rend; i++, r += width) { diff --git a/usr.sbin/pppd/auth.c b/usr.sbin/pppd/auth.c index 48f1c13dcd..336c3b624f 100644 --- a/usr.sbin/pppd/auth.c +++ b/usr.sbin/pppd/auth.c @@ -634,7 +634,7 @@ check_passwd(int unit, char *auser, int userlen, char *apasswd, int passwdlen, len = MIN(userlen, sizeof(user) - 1); BCOPY(auser, user, len); user[len] = '\0'; - *msg = (char *) 0; + *msg = NULL; /* * Open the file of pap secrets and scan for a suitable secret @@ -675,7 +675,7 @@ check_passwd(int unit, char *auser, int userlen, char *apasswd, int passwdlen, } if (ret == UPAP_AUTHNAK) { - if (*msg == (char *) 0) + if (*msg == NULL) *msg = "Login incorrect"; *msglen = strlen(*msg); /* @@ -695,7 +695,7 @@ check_passwd(int unit, char *auser, int userlen, char *apasswd, int passwdlen, } else { attempts = 0; /* Reset count */ - if (*msg == (char *) 0) + if (*msg == NULL) *msg = "Login ok"; *msglen = strlen(*msg); set_allowed_addrs(unit, addrs); @@ -1303,7 +1303,7 @@ ip_addr_check(u_int32_t addr, struct wordlist *addrs) if (ptr_mask != NULL) { int bit_count; - bit_count = (int) strtol (ptr_mask+1, (char **) 0, 10); + bit_count = (int) strtol (ptr_mask+1, NULL, 10); if (bit_count <= 0 || bit_count > 32) { syslog (LOG_WARNING, "invalid address length %s in auth. address list", diff --git a/usr.sbin/rpcbind/rpcb_svc_com.c b/usr.sbin/rpcbind/rpcb_svc_com.c index a27dfa5c48..0e72ef29dc 100644 --- a/usr.sbin/rpcbind/rpcb_svc_com.c +++ b/usr.sbin/rpcbind/rpcb_svc_com.c @@ -499,7 +499,7 @@ create_rmtcall_fd(struct netconfig *nconf) nconf->nc_device, errno); return (-1); } - xprt = svc_tli_create(fd, 0, (struct t_bind *) 0, 0, 0); + xprt = svc_tli_create(fd, 0, NULL, 0, 0); if (xprt == NULL) { if (debugging) fprintf(stderr,