Skip to contentSkip to conversation

appletalk/ddp.c: Neaten checksum function

PATCH Applied Joe Perches 2 participants 2 messages Nov 4, 2009 – Nov 8, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 appletalk/ddp.c: Neaten checksum function

atalk_sum_partial can now use the rol16 function in bitops.h

net/appletalk/ddp.c +2 -7
index abe3801..e6903db 100644
@@ -922,13 +922,8 @@ static unsigned long atalk_sum_partial(const unsigned char *data,
 {
 	/* This ought to be unwrapped neatly. I'll trust gcc for now */
 	while (len--) {
-		sum += *data;
-		sum <<= 1;
-		if (sum & 0x10000) {
-			sum++;
-			sum &= 0xffff;
-		}
-		data++;
+		sum += *data++;
+		sum = rol16(sum, 1);
 	}
 	return sum;
 }