Commit 44782fd8 authored by frei tycho's avatar frei tycho Committed by Johan Hedberg
Browse files

lib: change controlling expressions in if/while to Boolean



Use `do { ... } while (false)' instead of `do { ... } while (0)'.
Use comparisons with zero instead of implicitly testing integers.
Use comparisons with NULL instead of implicitly testing pointers.
Use comparisons with NUL instead of implicitly testing plain chars.
Use `bool' instead of `int' to represent Boolean values.
Use `while (true)' instead of `while (1)' to express infinite loops.

Signed-off-by: default avatarfrei tycho <tfrei@baumer.com>
parent 38267069
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@

uint8_t crc7_be(uint8_t seed, const uint8_t *src, size_t len)
{
	while (len--) {
	while (len-- != 0UL) {
		uint8_t e = seed ^ *src++;
		uint8_t f = e ^ (e >> 4) ^ (e >> 7);

+2 −2
Original line number Diff line number Diff line
@@ -37,13 +37,13 @@ uint8_t crc8(const uint8_t *src, size_t len, uint8_t polynomial, uint8_t initial

		for (j = 0; j < 8; j++) {
			if (reversed) {
				if (crc & 0x01) {
				if ((crc & 0x01) != 0) {
					crc = (crc >> 1) ^ polynomial;
				} else {
					crc >>= 1;
				}
			} else {
				if (crc & 0x80) {
				if ((crc & 0x80) != 0) {
					crc = (crc << 1) ^ polynomial;
				} else {
					crc <<= 1;
+1 −1
Original line number Diff line number Diff line
@@ -229,7 +229,7 @@ static chunkid_t alloc_chunk(struct z_heap *h, chunksz_t sz)
	 * fragmentation waste of the order of the block allocated
	 * only.
	 */
	if (b->next) {
	if (b->next != 0U) {
		chunkid_t first = b->next;
		int i = CONFIG_SYS_HEAP_ALLOC_LOOPS;
		do {
+1 −1
Original line number Diff line number Diff line
@@ -117,7 +117,7 @@ long strtol(const char *nptr, char **endptr, register int base)
	if (any < 0) {
		acc = neg ? LONG_MIN : LONG_MAX;
		errno = ERANGE;
	} else if (neg) {
	} else if (neg != 0) {
		acc = -acc;
	}

+1 −1
Original line number Diff line number Diff line
@@ -96,7 +96,7 @@ unsigned long strtoul(const char *nptr, char **endptr, register int base)
	if (any < 0) {
		acc = ULONG_MAX;
		errno = ERANGE;
	} else if (neg) {
	} else if (neg != 0) {
		acc = -acc;
	}
	if (endptr != NULL) {
Loading