[coreboot-gerrit] New patch to review for coreboot: src/lib: Move assignment out of if condition

Lee Leahy (leroy.p.leahy@intel.com) gerrit at coreboot.org
Sat Mar 11 03:28:32 CET 2017


Lee Leahy (leroy.p.leahy at intel.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/18761

-gerrit

commit 51c0496cb97a8b65b2c82864bdf4bc0e5631ae38
Author: Lee Leahy <leroy.p.leahy at intel.com>
Date:   Fri Mar 10 15:51:04 2017 -0800

    src/lib: Move assignment out of if condition
    
    Fix the following error detected by checkpatch:
    
    ERROR: do not use assignment in if condition
    
    TEST=Build and run on Galileo Gen2
    
    Change-Id: I5a08d1647db66bd5d480f81e90d473999c222acf
    Signed-off-by: Lee Leahy <Leroy.P.Leahy at intel.com>
---
 src/lib/jpeg.c    | 27 +++++++++++++++++----------
 src/lib/libgcov.c |  9 ++++++---
 2 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/src/lib/jpeg.c b/src/lib/jpeg.c
index 06c9d7c..cbd9eac 100644
--- a/src/lib/jpeg.c
+++ b/src/lib/jpeg.c
@@ -166,7 +166,8 @@ static int readtables(int till)
 	for (;;) {
 		if (getbyte() != 0xff)
 			return -1;
-		if ((m = getbyte()) == till)
+		m = getbyte();
+		if (m == till)
 			break;
 
 		switch (m) {
@@ -456,15 +457,20 @@ static int fillbits(struct in *in, int le, unsigned int bi)
 	}
 	while (le <= 24) {
 		b = *in->p++;
-		if (b == 0xff && (m = *in->p++) != 0) {
-			if (m == M_EOF) {
-				if (in->func && (m = in->func(in->data)) == 0)
-					continue;
+		if (b == 0xff) {
+			m = *in->p++;
+			if (m != 0) {
+				if (m == M_EOF) {
+					if (in->func) {
+						m = in->func(in->data);
+						if (m == 0)
+							continue;
+				}
+				in->marker = m;
+				if (le <= 16)
+					bi = bi << 16, le += 16;
+				break;
 			}
-			in->marker = m;
-			if (le <= 16)
-				bi = bi << 16, le += 16;
-			break;
 		}
 		bi = bi << 8 | b;
 		le += 8;
@@ -478,7 +484,8 @@ static int dec_readmarker(struct in *in)
 	int m;
 
 	in->left = fillbits(in, in->left, in->bits);
-	if ((m = in->marker) == 0)
+	m = in->marker;
+	if (m == 0)
 		return 0;
 	in->left = 0;
 	in->marker = 0;
diff --git a/src/lib/libgcov.c b/src/lib/libgcov.c
index 2cfda0a..bd719b8 100644
--- a/src/lib/libgcov.c
+++ b/src/lib/libgcov.c
@@ -496,7 +496,8 @@ gcov_exit(void)
 					if (length != GCOV_TAG_SUMMARY_LENGTH)
 						goto read_mismatch;
 					gcov_read_summary(&tmp);
-					if ((error = gcov_is_error()))
+					error = gcov_is_error();
+					if (error)
 						goto read_error;
 					if (summary_pos
 						|| tmp.checksum != crc32)
@@ -584,7 +585,8 @@ gcov_exit(void)
 							ci_ptr->num);
 						ci_ptr++;
 					}
-					if ((error = gcov_is_error()))
+					error = gcov_is_error();
+					if (error)
 						goto read_error;
 				}
 
@@ -713,7 +715,8 @@ read_fatal:;
 			fn_buffer = free_fn_data(gi_ptr, fn_buffer,
 				GCOV_COUNTERS);
 
-		if ((error = gcov_close()))
+		error = gcov_close()
+		if (error)
 			fprintf(stderr, error  < 0 ?
 				"profiling:%s:Overflow writing\n" :
 				"profiling:%s:Error writing\n",



More information about the coreboot-gerrit mailing list