Date: Sun, 26 Feb 2017 22:17:07 +0000 (UTC) From: "Pedro F. Giffuni" <pfg@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r314321 - head/usr.bin/dc Message-ID: <201702262217.v1QMH7ZK032087@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: pfg Date: Sun Feb 26 22:17:06 2017 New Revision: 314321 URL: https://svnweb.freebsd.org/changeset/base/314321 Log: dc(1): Merge minor changes from OpenBSD. Prefer setvbuf() to setlinebuf() for portability. Some style(9) and redundant tests for NULL. These are only meant to ease up merging newer changes but we are skipping changes done in order to accomodate OpenBSD's pledge support. Obtained from: OpenBSD MFC after: 2 weeks Modified: head/usr.bin/dc/bcode.c head/usr.bin/dc/dc.c head/usr.bin/dc/stack.c Modified: head/usr.bin/dc/bcode.c ============================================================================== --- head/usr.bin/dc/bcode.c Sun Feb 26 22:15:39 2017 (r314320) +++ head/usr.bin/dc/bcode.c Sun Feb 26 22:17:06 2017 (r314321) @@ -960,9 +960,8 @@ badd(void) struct number *a, *b, *r; a = pop_number(); - if (a == NULL) { + if (a == NULL) return; - } b = pop_number(); if (b == NULL) { push_number(a); @@ -987,9 +986,8 @@ bsub(void) struct number *a, *b, *r; a = pop_number(); - if (a == NULL) { + if (a == NULL) return; - } b = pop_number(); if (b == NULL) { push_number(a); @@ -1035,9 +1033,8 @@ bmul(void) struct number *a, *b, *r; a = pop_number(); - if (a == NULL) { + if (a == NULL) return; - } b = pop_number(); if (b == NULL) { push_number(a); @@ -1060,9 +1057,8 @@ bdiv(void) u_int scale; a = pop_number(); - if (a == NULL) { + if (a == NULL) return; - } b = pop_number(); if (b == NULL) { push_number(a); @@ -1097,9 +1093,8 @@ bmod(void) u_int scale; a = pop_number(); - if (a == NULL) { + if (a == NULL) return; - } b = pop_number(); if (b == NULL) { push_number(a); @@ -1134,9 +1129,8 @@ bdivmod(void) u_int scale; a = pop_number(); - if (a == NULL) { + if (a == NULL) return; - } b = pop_number(); if (b == NULL) { push_number(a); @@ -1176,9 +1170,8 @@ bexp(void) u_int rscale; p = pop_number(); - if (p == NULL) { + if (p == NULL) return; - } a = pop_number(); if (a == NULL) { push_number(p); @@ -1299,9 +1292,8 @@ bsqrt(void) onecount = 0; n = pop_number(); - if (n == NULL) { + if (n == NULL) return; - } if (BN_is_zero(n->number)) { r = new_number(); push_number(r); @@ -1342,9 +1334,8 @@ not(void) struct number *a; a = pop_number(); - if (a == NULL) { + if (a == NULL) return; - } a->scale = 0; bn_check(BN_set_word(a->number, BN_get_word(a->number) ? 0 : 1)); push_number(a); @@ -1363,9 +1354,8 @@ equal_numbers(void) struct number *a, *b, *r; a = pop_number(); - if (a == NULL) { + if (a == NULL) return; - } b = pop_number(); if (b == NULL) { push_number(a); @@ -1383,9 +1373,8 @@ less_numbers(void) struct number *a, *b, *r; a = pop_number(); - if (a == NULL) { + if (a == NULL) return; - } b = pop_number(); if (b == NULL) { push_number(a); @@ -1403,9 +1392,8 @@ lesseq_numbers(void) struct number *a, *b, *r; a = pop_number(); - if (a == NULL) { + if (a == NULL) return; - } b = pop_number(); if (b == NULL) { push_number(a); @@ -1736,9 +1724,8 @@ eval_tos(void) char *p; p = pop_string(); - if (p == NULL) - return; - eval_string(p); + if (p != NULL) + eval_string(p); } void Modified: head/usr.bin/dc/dc.c ============================================================================== --- head/usr.bin/dc/dc.c Sun Feb 26 22:15:39 2017 (r314320) +++ head/usr.bin/dc/dc.c Sun Feb 26 22:17:06 2017 (r314321) @@ -125,8 +125,8 @@ main(int argc, char *argv[]) if (!preproc_done) init_bmachine(extended_regs); - setlinebuf(stdout); - setlinebuf(stderr); + (void)setvbuf(stdout, NULL, _IOLBF, 0); + (void)setvbuf(stderr, NULL, _IOLBF, 0); if (argc > 1) usage(); Modified: head/usr.bin/dc/stack.c ============================================================================== --- head/usr.bin/dc/stack.c Sun Feb 26 22:15:39 2017 (r314320) +++ head/usr.bin/dc/stack.c Sun Feb 26 22:17:06 2017 (r314321) @@ -68,10 +68,8 @@ stack_free_value(struct value *v) free(v->u.string); break; } - if (v->array != NULL) { - array_free(v->array); - v->array = NULL; - } + array_free(v->array); + v->array = NULL; } /* Copy number or string content into already allocated target */ @@ -225,10 +223,8 @@ stack_popnumber(struct stack *stack) if (stack_empty(stack)) return (NULL); - if (stack->stack[stack->sp].array != NULL) { - array_free(stack->stack[stack->sp].array); - stack->stack[stack->sp].array = NULL; - } + array_free(stack->stack[stack->sp].array); + stack->stack[stack->sp].array = NULL; if (stack->stack[stack->sp].type != BCODE_NUMBER) { warnx("not a number"); /* XXX remove */ return (NULL); @@ -242,10 +238,8 @@ stack_popstring(struct stack *stack) if (stack_empty(stack)) return (NULL); - if (stack->stack[stack->sp].array != NULL) { - array_free(stack->stack[stack->sp].array); - stack->stack[stack->sp].array = NULL; - } + array_free(stack->stack[stack->sp].array); + stack->stack[stack->sp].array = NULL; if (stack->stack[stack->sp].type != BCODE_STRING) { warnx("not a string"); /* XXX remove */ return (NULL); @@ -257,9 +251,8 @@ void stack_clear(struct stack *stack) { - while (stack->sp >= 0) { + while (stack->sp >= 0) stack_free_value(&stack->stack[stack->sp--]); - } free(stack->stack); stack_init(stack); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201702262217.v1QMH7ZK032087>