xref: /OK3568_Linux_fs/buildroot/package/netcat/0001-signed-bit-counting.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1# Fix the endian-specific bit-counting code so that it works.
2# SF:1068324 "netcat_flag_count() fix"
3#   http://sourceforge.net/tracker/?func=detail&aid=1205729&group_id=52204&atid=466046
4# SF:1205729 "doen't work on arm linux platform":
5#   http://sourceforge.net/tracker/?func=detail&aid=1068324&group_id=52204&atid=466046
6
7Index: netcat-0.7.1/src/flagset.c
8===================================================================
9--- netcat-0.7.1.orig/src/flagset.c	2010-07-19 13:51:46.000000000 +0100
10+++ netcat-0.7.1/src/flagset.c	2010-07-19 13:52:27.000000000 +0100
11@@ -134,7 +134,7 @@
12
13 int netcat_flag_count(void)
14 {
15-  register char c;
16+  register unsigned char c;
17   register int i;
18   int ret = 0;
19
20@@ -154,8 +154,8 @@
21 	Assumed that the bit number 1 is the sign, and that we will shift the
22 	bit 1 (or the bit that takes its place later) until the the most right,
23 	WHY it has to keep the wrong sign? */
24-      ret -= (c >> 7);
25-      c <<= 1;
26+      ret += c&1;
27+      c>>=1;
28     }
29   }
30
31