Skip to contentSkip to conversation

m68k: amiflop: *ptr incremented past 0x4489

PATCH In review Roel Kluin 2 participants 2 messages Feb 11, 2009 – Feb 13, 2009 Block layer

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 m68k: amiflop: *ptr incremented past 0x4489

With while (*ptr++ != 0x4489) { ... } *ptr will be incremented past 0x4489 after the loop.

---

drivers/block/amiflop.c +2 -2
index 8df436f..3320b00 100644
@@ -662,8 +662,8 @@ static unsigned long scan_sync(unsigned long raw, unsigned long end)
 {
 	ushort *ptr = (ushort *)raw, *endp = (ushort *)end;
 
-	while (ptr < endp && *ptr++ != 0x4489)
-		;
+	while (ptr < endp && *ptr != 0x4489)
+		++ptr;
 	if (ptr < endp) {
 		while (*ptr == 0x4489 && ptr < endp)
 			ptr++;
#1 lore raw
Quoted 3 lines · Roel Kluin

With while (*ptr++ != 0x4489) { ... } *ptr will be incremented past 0x4489 after
the loop.

Yes, that is on purpose. The magic bytes of 0x4489 are a sync mark, the interesting stuff always starts afterwards. The whole decoding routing uses the current pointer the way that it always points to the next unprocessed position when it arrives at the next segment of decoding. I'd rather have this consistent in the whole driver.

Bye,

Joerg