Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Mar 2017 05:36:32 +0000 (UTC)
From:      "Pedro F. Giffuni" <pfg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r315135 - stable/10/usr.bin/dc
Message-ID:  <201703120536.v2C5aW9K071574@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: pfg
Date: Sun Mar 12 05:36:31 2017
New Revision: 315135
URL: https://svnweb.freebsd.org/changeset/base/315135

Log:
  MFC r314321:
  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.
  
  Obtained from:	OpenBSD

Modified:
  stable/10/usr.bin/dc/bcode.c
  stable/10/usr.bin/dc/dc.c
  stable/10/usr.bin/dc/stack.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.bin/dc/bcode.c
==============================================================================
--- stable/10/usr.bin/dc/bcode.c	Sun Mar 12 05:35:28 2017	(r315134)
+++ stable/10/usr.bin/dc/bcode.c	Sun Mar 12 05:36:31 2017	(r315135)
@@ -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: stable/10/usr.bin/dc/dc.c
==============================================================================
--- stable/10/usr.bin/dc/dc.c	Sun Mar 12 05:35:28 2017	(r315134)
+++ stable/10/usr.bin/dc/dc.c	Sun Mar 12 05:36:31 2017	(r315135)
@@ -120,8 +120,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: stable/10/usr.bin/dc/stack.c
==============================================================================
--- stable/10/usr.bin/dc/stack.c	Sun Mar 12 05:35:28 2017	(r315134)
+++ stable/10/usr.bin/dc/stack.c	Sun Mar 12 05:36:31 2017	(r315135)
@@ -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?201703120536.v2C5aW9K071574>