Author: pfg Date: Sun Apr 10 23:47:40 2016 New Revision: 297795 URL: https://svnweb.freebsd.org/changeset/base/297795
Log: lpr: replace 0 with NULL for pointers. Found with devel/coccinelle. Reviewed by: gad Modified: head/usr.sbin/lpr/chkprintcap/chkprintcap.c head/usr.sbin/lpr/common_source/common.c head/usr.sbin/lpr/common_source/net.c head/usr.sbin/lpr/common_source/printcap.c head/usr.sbin/lpr/common_source/request.c head/usr.sbin/lpr/common_source/rmjob.c head/usr.sbin/lpr/lpc/lpc.c head/usr.sbin/lpr/lpd/printjob.c Modified: head/usr.sbin/lpr/chkprintcap/chkprintcap.c ============================================================================== --- head/usr.sbin/lpr/chkprintcap/chkprintcap.c Sun Apr 10 23:17:06 2016 (r297794) +++ head/usr.sbin/lpr/chkprintcap/chkprintcap.c Sun Apr 10 23:47:40 2016 (r297795) @@ -222,7 +222,7 @@ note_spool_dir(const struct printer *pp, struct dirlist *dp, *dp2, *last; dp = malloc(sizeof *dp); - if (dp == 0) + if (dp == NULL) err(++problems, "malloc(%lu)", (u_long)sizeof *dp); dp->stab = *st; @@ -233,7 +233,7 @@ note_spool_dir(const struct printer *pp, if (dp->path == 0) err(++problems, "malloc(%lu)", strlen(pp->spool_dir) + 1UL); - last = 0; + last = NULL; LIST_FOREACH(dp2, &dirlist, link) { if(!lessp(dp, dp2)) break; @@ -255,7 +255,7 @@ check_spool_dirs(void) for (dp = LIST_FIRST(&dirlist); dp; dp = dp2) { dp2 = LIST_NEXT(dp, link); - if (dp2 != 0 && equal(dp, dp2)) { + if (dp2 != NULL && equal(dp, dp2)) { ++problems; if (strcmp(dp->path, dp2->path) == 0) { warnx("%s and %s share the same spool, %s", @@ -289,7 +289,7 @@ make_spool_dir(const struct printer *pp) return; } gr = getgrnam("daemon"); - if (gr == 0) + if (gr == NULL) errx(++problems, "cannot locate daemon group"); if (chown(sd, pp->daemon_user, gr->gr_gid) < 0) { Modified: head/usr.sbin/lpr/common_source/common.c ============================================================================== --- head/usr.sbin/lpr/common_source/common.c Sun Apr 10 23:17:06 2016 (r297794) +++ head/usr.sbin/lpr/common_source/common.c Sun Apr 10 23:47:40 2016 (r297795) @@ -282,7 +282,7 @@ lock_file_name(const struct printer *pp, { static char staticbuf[MAXPATHLEN]; - if (buf == 0) + if (buf == NULL) buf = staticbuf; if (len == 0) len = MAXPATHLEN; @@ -300,7 +300,7 @@ status_file_name(const struct printer *p { static char staticbuf[MAXPATHLEN]; - if (buf == 0) + if (buf == NULL) buf = staticbuf; if (len == 0) len = MAXPATHLEN; Modified: head/usr.sbin/lpr/common_source/net.c ============================================================================== --- head/usr.sbin/lpr/common_source/net.c Sun Apr 10 23:17:06 2016 (r297794) +++ head/usr.sbin/lpr/common_source/net.c Sun Apr 10 23:47:40 2016 (r297795) @@ -280,7 +280,7 @@ writel(int strm, ...) if (n > NIOV) { iovp = malloc(n * sizeof *iovp); - if (iovp == 0) + if (iovp == NULL) return -1; } Modified: head/usr.sbin/lpr/common_source/printcap.c ============================================================================== --- head/usr.sbin/lpr/common_source/printcap.c Sun Apr 10 23:17:06 2016 (r297794) +++ head/usr.sbin/lpr/common_source/printcap.c Sun Apr 10 23:47:40 2016 (r297795) @@ -220,7 +220,7 @@ getprintcap_int(char *bp, struct printer char *rp_name; int error; - if ((pp->printer = capdb_canonical_name(bp)) == 0) + if ((pp->printer = capdb_canonical_name(bp)) == NULL) return PCAPERR_OSERR; #define CHK(x) do {if ((x) == PCAPERR_OSERR) return PCAPERR_OSERR;}while(0) @@ -386,7 +386,7 @@ capdb_getaltstr(char *bp, const char *sh return status; if (dflt) { *result = strdup(dflt); - if (*result == 0) + if (*result == NULL) return PCAPERR_OSERR; return strlen(*result); } @@ -439,9 +439,9 @@ capdb_canonical_name(const char *bp) const char *nameend; nameend = strpbrk(bp, "|:"); - if (nameend == 0) + if (nameend == NULL) nameend = bp + 1; - if ((retval = malloc(nameend - bp + 1)) != 0) { + if ((retval = malloc(nameend - bp + 1)) != NULL) { retval[0] = '\0'; strncat(retval, bp, nameend - bp); } Modified: head/usr.sbin/lpr/common_source/request.c ============================================================================== --- head/usr.sbin/lpr/common_source/request.c Sun Apr 10 23:17:06 2016 (r297794) +++ head/usr.sbin/lpr/common_source/request.c Sun Apr 10 23:47:40 2016 (r297795) @@ -69,11 +69,11 @@ free_request(struct request *rp) free(rp->prettyname); if (rp->authinfo) free(rp->authinfo); - while ((ru = TAILQ_FIRST(&rp->users)) != 0) { + while ((ru = TAILQ_FIRST(&rp->users)) != NULL) { TAILQ_REMOVE(&rp->users, ru, ru_link); free(ru); } - while ((rj = TAILQ_FIRST(&rp->jobids)) != 0) { + while ((rj = TAILQ_FIRST(&rp->jobids)) != NULL) { TAILQ_REMOVE(&rp->jobids, rj, rj_link); free(rj); } Modified: head/usr.sbin/lpr/common_source/rmjob.c ============================================================================== --- head/usr.sbin/lpr/common_source/rmjob.c Sun Apr 10 23:17:06 2016 (r297794) +++ head/usr.sbin/lpr/common_source/rmjob.c Sun Apr 10 23:47:40 2016 (r297795) @@ -332,7 +332,7 @@ rmremote(const struct printer *pp) else niov = 4 + requests + 1; iov = malloc(niov * sizeof *iov); - if (iov == 0) + if (iov == NULL) fatal(pp, "out of memory in rmremote()"); iov[0].iov_base = "\5"; iov[1].iov_base = pp->remote_queue; Modified: head/usr.sbin/lpr/lpc/lpc.c ============================================================================== --- head/usr.sbin/lpr/lpc/lpc.c Sun Apr 10 23:17:06 2016 (r297794) +++ head/usr.sbin/lpr/lpc/lpc.c Sun Apr 10 23:47:40 2016 (r297795) @@ -103,7 +103,7 @@ main(int argc, char *argv[]) printf("?Ambiguous command\n"); exit(1); } - if (c == 0) { + if (c == NULL) { printf("?Invalid command\n"); exit(1); } @@ -112,7 +112,7 @@ main(int argc, char *argv[]) printf("?Privileged command\n"); exit(1); } - if (c->c_generic != 0) + if (c->c_generic != NULL) generic(c->c_generic, c->c_opts, c->c_handler, argc, argv); else @@ -205,7 +205,7 @@ cmdscanner(void) printf("?Ambiguous command\n"); continue; } - if (c == 0) { + if (c == NULL) { printf("?Invalid command\n"); continue; } @@ -222,7 +222,7 @@ cmdscanner(void) * routine might also be set on a generic routine for * initial parameter processing. */ - if (c->c_generic != 0) + if (c->c_generic != NULL) generic(c->c_generic, c->c_opts, c->c_handler, margc, margv); else @@ -239,7 +239,7 @@ getcmd(const char *name) longest = 0; nmatches = 0; - found = 0; + found = NULL; for (c = cmdtab; (p = c->c_name); c++) { for (q = name; *q == *p++; q++) if (*q == 0) /* exact match? */ @@ -283,7 +283,7 @@ makeargv(void) break; *cp++ = '\0'; } - *argp++ = 0; + *argp++ = NULL; } #define HELPINDENT (sizeof ("directory")) Modified: head/usr.sbin/lpr/lpd/printjob.c ============================================================================== --- head/usr.sbin/lpr/lpd/printjob.c Sun Apr 10 23:17:06 2016 (r297794) +++ head/usr.sbin/lpr/lpd/printjob.c Sun Apr 10 23:47:40 2016 (r297795) @@ -673,7 +673,7 @@ print(struct printer *pp, int format, ch av[i++] = "-L"; av[i++] = *locale ? locale : "C"; av[i++] = "-F"; - av[i] = 0; + av[i] = NULL; fo = ofd; goto start; } @@ -795,7 +795,7 @@ print(struct printer *pp, int format, ch av[n++] = "-h"; av[n++] = origin_host; av[n++] = pp->acct_file; - av[n] = 0; + av[n] = NULL; fo = pfd; if (of_pid > 0) { /* stop output filter */ write(ofd, "\031\1", 2); @@ -1737,7 +1737,7 @@ init(struct printer *pp) sprintf(&length[2], "%ld", pp->page_length); sprintf(&pxwidth[2], "%ld", pp->page_pwidth); sprintf(&pxlength[2], "%ld", pp->page_plength); - if ((s = checkremote(pp)) != 0) { + if ((s = checkremote(pp)) != NULL) { syslog(LOG_WARNING, "%s", s); free(s); } _______________________________________________ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"