Skip to contentSkip to conversation

staging: unsigned won't get negative after subtraction

PATCH Applied Roel Kluin 2 participants 2 messages Jan 18, 2009 – Jan 21, 2009 Staging

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 staging: unsigned won't get negative after subtraction

This also contains a fix I sent earlier, I'm not sure how split this patch, but this is about the second hunk.

vi drivers/staging/meilhaus/me6000_ao.h +112
typedef struct me6000_ao_subdevice {
...

        unsigned int ao_idx;

...
};

Since unsigned, it won't get negative after subtraction.

---

drivers/staging/meilhaus/me6000_ao.c +6 -5
index 94f0123..dcb3526 100644
@@ -1063,7 +1063,7 @@ static int me6000_ao_io_stream_config(me_subdevice_t * subdevice,
 	}
 
 	if (flags & ME_IO_STREAM_CONFIG_HARDWARE_ONLY) {
-		if (!flags & ME_IO_STREAM_CONFIG_WRAPAROUND) {
+		if (!(flags & ME_IO_STREAM_CONFIG_WRAPAROUND)) {
 			PERROR
 			    ("Hardware ME_IO_STREAM_CONFIG_HARDWARE_ONLY has to be with ME_IO_STREAM_CONFIG_WRAPAROUND.\n");
 			return ME_ERRNO_INVALID_FLAGS;
@@ -2825,10 +2825,11 @@ int inline ao_stop_immediately(me6000_ao_subdevice_t * instance)
 	int i;
 	uint32_t single_mask;
 
-	single_mask =
-	    (instance->ao_idx - ME6000_AO_SINGLE_STATUS_OFFSET <
-	     0) ? 0x0000 : (0x0001 << (instance->ao_idx -
-				       ME6000_AO_SINGLE_STATUS_OFFSET));
+	if (instance->ao_idx < ME6000_AO_SINGLE_STATUS_OFFSET)
+		single_mask = 0x0000;
+	else
+		single_mask = 0x0001 << (instance->ao_idx -
+				ME6000_AO_SINGLE_STATUS_OFFSET);
 
 	timeout =
 	    (instance->hardware_stop_delay >
#1 lore raw

patch staging-meilhaus-unsigned-won-t-get-negative-after-subtraction.patch added to gregkh-2.6 tree

This is a note to let you know that I've just added the patch titled

Subject: Staging: meilhaus: unsigned won't get negative after subtraction

to my gregkh-2.6 tree. Its filename is

staging-meilhaus-unsigned-won-t-get-negative-after-subtraction.patch

This tree can be found at
http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/

Quoted 1 line

From [email protected] Wed Jan 21 09:47:26 2009

From: Roel Kluin <[email protected]>
Date: Sun, 18 Jan 2009 15:34:55 +0100
Subject: Staging: meilhaus: unsigned won't get negative after subtraction
To: <[email protected]>, <[email protected]>, Greg KH <[email protected]>
Cc: lkml <[email protected]>
Message-ID: <[email protected]>

Since unsigned, it won't get negative after subtraction.

---
 drivers/staging/meilhaus/me6000_ao.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/staging/meilhaus/me6000_ao.c +5 -4
@@ -2825,10 +2825,11 @@ int inline ao_stop_immediately(me6000_ao
 	int i;
 	uint32_t single_mask;
 
-	single_mask =
-	    (instance->ao_idx - ME6000_AO_SINGLE_STATUS_OFFSET <
-	     0) ? 0x0000 : (0x0001 << (instance->ao_idx -
-				       ME6000_AO_SINGLE_STATUS_OFFSET));
+	if (instance->ao_idx < ME6000_AO_SINGLE_STATUS_OFFSET)
+		single_mask = 0x0000;
+	else
+		single_mask = 0x0001 << (instance->ao_idx -
+				ME6000_AO_SINGLE_STATUS_OFFSET);
 
 	timeout =
 	    (instance->hardware_stop_delay >

Patches currently in gregkh-2.6 which might be from [email protected] are

staging/staging-meilhaus-unsigned-won-t-get-negative-after-subtraction.patch staging/staging-otus-logical-bit-and-confusion.patch