aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bsd_comp.c
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2006-09-13 13:24:59 -0400
committerJeff Garzik <jeff@garzik.org>2006-09-13 13:24:59 -0400
commit6aa20a2235535605db6d6d2bd850298b2fe7f31e (patch)
treedf0b855043407b831d57f2f2c271f8aab48444f4 /drivers/net/bsd_comp.c
parent7a291083225af6e22ffaa46b3d91cfc1a1ccaab4 (diff)
drivers/net: Trim trailing whitespace
Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/bsd_comp.c')
-rw-r--r--drivers/net/bsd_comp.c68
1 files changed, 34 insertions, 34 deletions
diff --git a/drivers/net/bsd_comp.c b/drivers/net/bsd_comp.c
index fb4098ed469e..bae1de1e7802 100644
--- a/drivers/net/bsd_comp.c
+++ b/drivers/net/bsd_comp.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Update: The Berkeley copyright was changed, and the change 2 * Update: The Berkeley copyright was changed, and the change
3 * is retroactive to all "true" BSD software (ie everything 3 * is retroactive to all "true" BSD software (ie everything
4 * from UCB as opposed to other peoples code that just carried 4 * from UCB as opposed to other peoples code that just carried
5 * the same license). The new copyright doesn't clash with the 5 * the same license). The new copyright doesn't clash with the
@@ -256,9 +256,9 @@ static int bsd_check (struct bsd_db *db) /* 1=output CLEAR */
256 db->in_count -= (db->in_count >> 2); 256 db->in_count -= (db->in_count >> 2);
257 db->bytes_out -= (db->bytes_out >> 2); 257 db->bytes_out -= (db->bytes_out >> 2);
258 } 258 }
259 259
260 db->checkpoint = db->in_count + CHECK_GAP; 260 db->checkpoint = db->in_count + CHECK_GAP;
261 261
262 if (db->max_ent >= db->maxmaxcode) 262 if (db->max_ent >= db->maxmaxcode)
263 { 263 {
264 /* Reset the dictionary only if the ratio is worse, 264 /* Reset the dictionary only if the ratio is worse,
@@ -274,7 +274,7 @@ static int bsd_check (struct bsd_db *db) /* 1=output CLEAR */
274 { 274 {
275 new_ratio /= db->bytes_out; 275 new_ratio /= db->bytes_out;
276 } 276 }
277 277
278 if (new_ratio < db->ratio || new_ratio < 1 * RATIO_SCALE) 278 if (new_ratio < db->ratio || new_ratio < 1 * RATIO_SCALE)
279 { 279 {
280 bsd_clear (db); 280 bsd_clear (db);
@@ -293,7 +293,7 @@ static int bsd_check (struct bsd_db *db) /* 1=output CLEAR */
293static void bsd_comp_stats (void *state, struct compstat *stats) 293static void bsd_comp_stats (void *state, struct compstat *stats)
294 { 294 {
295 struct bsd_db *db = (struct bsd_db *) state; 295 struct bsd_db *db = (struct bsd_db *) state;
296 296
297 stats->unc_bytes = db->uncomp_bytes; 297 stats->unc_bytes = db->uncomp_bytes;
298 stats->unc_packets = db->uncomp_count; 298 stats->unc_packets = db->uncomp_count;
299 stats->comp_bytes = db->comp_bytes; 299 stats->comp_bytes = db->comp_bytes;
@@ -325,7 +325,7 @@ static void bsd_reset (void *state)
325static void bsd_free (void *state) 325static void bsd_free (void *state)
326{ 326{
327 struct bsd_db *db = state; 327 struct bsd_db *db = state;
328 328
329 if (!db) 329 if (!db)
330 return; 330 return;
331 331
@@ -468,7 +468,7 @@ static int bsd_init (void *state, unsigned char *options,
468 { 468 {
469 struct bsd_db *db = state; 469 struct bsd_db *db = state;
470 int indx; 470 int indx;
471 471
472 if ((opt_len != 3) || (options[0] != CI_BSD_COMPRESS) || (options[1] != 3) 472 if ((opt_len != 3) || (options[0] != CI_BSD_COMPRESS) || (options[1] != 3)
473 || (BSD_VERSION(options[2]) != BSD_CURRENT_VERSION) 473 || (BSD_VERSION(options[2]) != BSD_CURRENT_VERSION)
474 || (BSD_NBITS(options[2]) != db->maxbits) 474 || (BSD_NBITS(options[2]) != db->maxbits)
@@ -500,9 +500,9 @@ static int bsd_init (void *state, unsigned char *options,
500 if (debug) 500 if (debug)
501#endif 501#endif
502 db->debug = 1; 502 db->debug = 1;
503 503
504 bsd_reset(db); 504 bsd_reset(db);
505 505
506 return 1; 506 return 1;
507 } 507 }
508 508
@@ -660,7 +660,7 @@ static int bsd_compress (void *state, unsigned char *rptr, unsigned char *obuf,
660 fcode = BSD_KEY (ent, c); 660 fcode = BSD_KEY (ent, c);
661 hval = BSD_HASH (ent, c, hshift); 661 hval = BSD_HASH (ent, c, hshift);
662 dictp = dict_ptr (db, hval); 662 dictp = dict_ptr (db, hval);
663 663
664 /* Validate and then check the entry. */ 664 /* Validate and then check the entry. */
665 if (dictp->codem1 >= max_ent) 665 if (dictp->codem1 >= max_ent)
666 { 666 {
@@ -672,7 +672,7 @@ static int bsd_compress (void *state, unsigned char *rptr, unsigned char *obuf,
672 ent = dictp->codem1 + 1; 672 ent = dictp->codem1 + 1;
673 continue; /* found (prefix,suffix) */ 673 continue; /* found (prefix,suffix) */
674 } 674 }
675 675
676 /* continue probing until a match or invalid entry */ 676 /* continue probing until a match or invalid entry */
677 disp = (hval == 0) ? 1 : hval; 677 disp = (hval == 0) ? 1 : hval;
678 678
@@ -693,10 +693,10 @@ static int bsd_compress (void *state, unsigned char *rptr, unsigned char *obuf,
693 693
694 ent = dictp->codem1 + 1; /* finally found (prefix,suffix) */ 694 ent = dictp->codem1 + 1; /* finally found (prefix,suffix) */
695 continue; 695 continue;
696 696
697nomatch: 697nomatch:
698 OUTPUT(ent); /* output the prefix */ 698 OUTPUT(ent); /* output the prefix */
699 699
700 /* code -> hashtable */ 700 /* code -> hashtable */
701 if (max_ent < db->maxmaxcode) 701 if (max_ent < db->maxmaxcode)
702 { 702 {
@@ -710,7 +710,7 @@ nomatch:
710 db->n_bits = ++n_bits; 710 db->n_bits = ++n_bits;
711 mxcode = MAXCODE (n_bits); 711 mxcode = MAXCODE (n_bits);
712 } 712 }
713 713
714 /* Invalidate old hash table entry using 714 /* Invalidate old hash table entry using
715 * this code, and then take it over. 715 * this code, and then take it over.
716 */ 716 */
@@ -738,7 +738,7 @@ nomatch:
738 } 738 }
739 ent = c; 739 ent = c;
740 } 740 }
741 741
742 OUTPUT(ent); /* output the last code */ 742 OUTPUT(ent); /* output the last code */
743 743
744 db->bytes_out += olen - PPP_HDRLEN - BSD_OVHD; 744 db->bytes_out += olen - PPP_HDRLEN - BSD_OVHD;
@@ -760,7 +760,7 @@ nomatch:
760 { 760 {
761 OUTPUT (CLEAR); 761 OUTPUT (CLEAR);
762 } 762 }
763 763
764 /* 764 /*
765 * Pad dribble bits of last code with ones. 765 * Pad dribble bits of last code with ones.
766 * Do not emit a completely useless byte of ones. 766 * Do not emit a completely useless byte of ones.
@@ -770,7 +770,7 @@ nomatch:
770 { 770 {
771 PUTBYTE((accm | (0xff << (bitno-8))) >> 24); 771 PUTBYTE((accm | (0xff << (bitno-8))) >> 24);
772 } 772 }
773 773
774 /* 774 /*
775 * Increase code size if we would have without the packet 775 * Increase code size if we would have without the packet
776 * boundary because the decompressor will do so. 776 * boundary because the decompressor will do so.
@@ -856,7 +856,7 @@ static int bsd_decompress (void *state, unsigned char *ibuf, int isize,
856 bitno = 32; /* 1st valid bit in accm */ 856 bitno = 32; /* 1st valid bit in accm */
857 n_bits = db->n_bits; 857 n_bits = db->n_bits;
858 tgtbitno = 32 - n_bits; /* bitno when we have a code */ 858 tgtbitno = 32 - n_bits; /* bitno when we have a code */
859 859
860 /* 860 /*
861 * Save the address/control from the PPP header 861 * Save the address/control from the PPP header
862 * and then get the sequence number. 862 * and then get the sequence number.
@@ -869,7 +869,7 @@ static int bsd_decompress (void *state, unsigned char *ibuf, int isize,
869 869
870 ibuf += (PPP_HDRLEN + 2); 870 ibuf += (PPP_HDRLEN + 2);
871 ilen = isize - (PPP_HDRLEN + 2); 871 ilen = isize - (PPP_HDRLEN + 2);
872 872
873 /* 873 /*
874 * Check the sequence number and give up if it differs from 874 * Check the sequence number and give up if it differs from
875 * the value we're expecting. 875 * the value we're expecting.
@@ -897,7 +897,7 @@ static int bsd_decompress (void *state, unsigned char *ibuf, int isize,
897 *wptr++ = adrs; 897 *wptr++ = adrs;
898 *wptr++ = ctrl; 898 *wptr++ = ctrl;
899 *wptr++ = 0; 899 *wptr++ = 0;
900 900
901 oldcode = CLEAR; 901 oldcode = CLEAR;
902 explen = 3; 902 explen = 3;
903 903
@@ -934,7 +934,7 @@ static int bsd_decompress (void *state, unsigned char *ibuf, int isize,
934 /* 934 /*
935 * The dictionary must only be cleared at the end of a packet. 935 * The dictionary must only be cleared at the end of a packet.
936 */ 936 */
937 937
938 if (incode == CLEAR) 938 if (incode == CLEAR)
939 { 939 {
940 if (ilen > 0) 940 if (ilen > 0)
@@ -945,7 +945,7 @@ static int bsd_decompress (void *state, unsigned char *ibuf, int isize,
945 } 945 }
946 return DECOMP_FATALERROR; /* probably a bug */ 946 return DECOMP_FATALERROR; /* probably a bug */
947 } 947 }
948 948
949 bsd_clear(db); 949 bsd_clear(db);
950 break; 950 break;
951 } 951 }
@@ -962,7 +962,7 @@ static int bsd_decompress (void *state, unsigned char *ibuf, int isize,
962 } 962 }
963 return DECOMP_FATALERROR; /* probably a bug */ 963 return DECOMP_FATALERROR; /* probably a bug */
964 } 964 }
965 965
966 /* Special case for KwKwK string. */ 966 /* Special case for KwKwK string. */
967 if (incode > max_ent) 967 if (incode > max_ent)
968 { 968 {
@@ -974,7 +974,7 @@ static int bsd_decompress (void *state, unsigned char *ibuf, int isize,
974 finchar = incode; 974 finchar = incode;
975 extra = 0; 975 extra = 0;
976 } 976 }
977 977
978 codelen = *(lens_ptr (db, finchar)); 978 codelen = *(lens_ptr (db, finchar));
979 explen += codelen + extra; 979 explen += codelen + extra;
980 if (explen > osize) 980 if (explen > osize)
@@ -989,7 +989,7 @@ static int bsd_decompress (void *state, unsigned char *ibuf, int isize,
989 } 989 }
990 return DECOMP_FATALERROR; 990 return DECOMP_FATALERROR;
991 } 991 }
992 992
993 /* 993 /*
994 * Decode this code and install it in the decompressed buffer. 994 * Decode this code and install it in the decompressed buffer.
995 */ 995 */
@@ -999,7 +999,7 @@ static int bsd_decompress (void *state, unsigned char *ibuf, int isize,
999 while (finchar > LAST) 999 while (finchar > LAST)
1000 { 1000 {
1001 struct bsd_dict *dictp2 = dict_ptr (db, finchar); 1001 struct bsd_dict *dictp2 = dict_ptr (db, finchar);
1002 1002
1003 dictp = dict_ptr (db, dictp2->cptr); 1003 dictp = dict_ptr (db, dictp2->cptr);
1004#ifdef DEBUG 1004#ifdef DEBUG
1005 if (--codelen <= 0 || dictp->codem1 != finchar-1) 1005 if (--codelen <= 0 || dictp->codem1 != finchar-1)
@@ -1029,7 +1029,7 @@ static int bsd_decompress (void *state, unsigned char *ibuf, int isize,
1029 finchar = dictp->f.hs.prefix; 1029 finchar = dictp->f.hs.prefix;
1030 } 1030 }
1031 *--p = finchar; 1031 *--p = finchar;
1032 1032
1033#ifdef DEBUG 1033#ifdef DEBUG
1034 if (--codelen != 0) 1034 if (--codelen != 0)
1035 { 1035 {
@@ -1037,12 +1037,12 @@ static int bsd_decompress (void *state, unsigned char *ibuf, int isize,
1037 db->unit, codelen, incode, max_ent); 1037 db->unit, codelen, incode, max_ent);
1038 } 1038 }
1039#endif 1039#endif
1040 1040
1041 if (extra) /* the KwKwK case again */ 1041 if (extra) /* the KwKwK case again */
1042 { 1042 {
1043 *wptr++ = finchar; 1043 *wptr++ = finchar;
1044 } 1044 }
1045 1045
1046 /* 1046 /*
1047 * If not first code in a packet, and 1047 * If not first code in a packet, and
1048 * if not out of code space, then allocate a new code. 1048 * if not out of code space, then allocate a new code.
@@ -1057,11 +1057,11 @@ static int bsd_decompress (void *state, unsigned char *ibuf, int isize,
1057 unsigned short *lens1, *lens2; 1057 unsigned short *lens1, *lens2;
1058 unsigned long fcode; 1058 unsigned long fcode;
1059 int hval, disp, indx; 1059 int hval, disp, indx;
1060 1060
1061 fcode = BSD_KEY(oldcode,finchar); 1061 fcode = BSD_KEY(oldcode,finchar);
1062 hval = BSD_HASH(oldcode,finchar,db->hshift); 1062 hval = BSD_HASH(oldcode,finchar,db->hshift);
1063 dictp = dict_ptr (db, hval); 1063 dictp = dict_ptr (db, hval);
1064 1064
1065 /* look for a free hash table entry */ 1065 /* look for a free hash table entry */
1066 if (dictp->codem1 < max_ent) 1066 if (dictp->codem1 < max_ent)
1067 { 1067 {
@@ -1077,7 +1077,7 @@ static int bsd_decompress (void *state, unsigned char *ibuf, int isize,
1077 } 1077 }
1078 while (dictp->codem1 < max_ent); 1078 while (dictp->codem1 < max_ent);
1079 } 1079 }
1080 1080
1081 /* 1081 /*
1082 * Invalidate previous hash table entry 1082 * Invalidate previous hash table entry
1083 * assigned this code, and then take it over 1083 * assigned this code, and then take it over
@@ -1101,7 +1101,7 @@ static int bsd_decompress (void *state, unsigned char *ibuf, int isize,
1101 lens1 = lens_ptr (db, max_ent); 1101 lens1 = lens_ptr (db, max_ent);
1102 lens2 = lens_ptr (db, oldcode); 1102 lens2 = lens_ptr (db, oldcode);
1103 *lens1 = *lens2 + 1; 1103 *lens1 = *lens2 + 1;
1104 1104
1105 /* Expand code size if needed. */ 1105 /* Expand code size if needed. */
1106 if (max_ent >= MAXCODE(n_bits) && max_ent < db->maxmaxcode) 1106 if (max_ent >= MAXCODE(n_bits) && max_ent < db->maxmaxcode)
1107 { 1107 {
@@ -1127,7 +1127,7 @@ static int bsd_decompress (void *state, unsigned char *ibuf, int isize,
1127 } 1127 }
1128 return explen; 1128 return explen;
1129 } 1129 }
1130 1130
1131/************************************************************* 1131/*************************************************************
1132 * Table of addresses for the BSD compression module 1132 * Table of addresses for the BSD compression module
1133 *************************************************************/ 1133 *************************************************************/