diff options
Diffstat (limited to 'fs/jffs2/compr_rtime.c')
-rw-r--r-- | fs/jffs2/compr_rtime.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/fs/jffs2/compr_rtime.c b/fs/jffs2/compr_rtime.c index 393129418666..2eb1b7428d16 100644 --- a/fs/jffs2/compr_rtime.c +++ b/fs/jffs2/compr_rtime.c | |||
@@ -24,8 +24,8 @@ | |||
24 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
25 | #include <linux/types.h> | 25 | #include <linux/types.h> |
26 | #include <linux/errno.h> | 26 | #include <linux/errno.h> |
27 | #include <linux/string.h> | 27 | #include <linux/string.h> |
28 | #include <linux/jffs2.h> | 28 | #include <linux/jffs2.h> |
29 | #include "compr.h" | 29 | #include "compr.h" |
30 | 30 | ||
31 | /* _compress returns the compressed size, -1 if bigger */ | 31 | /* _compress returns the compressed size, -1 if bigger */ |
@@ -38,19 +38,19 @@ static int jffs2_rtime_compress(unsigned char *data_in, | |||
38 | int outpos = 0; | 38 | int outpos = 0; |
39 | int pos=0; | 39 | int pos=0; |
40 | 40 | ||
41 | memset(positions,0,sizeof(positions)); | 41 | memset(positions,0,sizeof(positions)); |
42 | 42 | ||
43 | while (pos < (*sourcelen) && outpos <= (*dstlen)-2) { | 43 | while (pos < (*sourcelen) && outpos <= (*dstlen)-2) { |
44 | int backpos, runlen=0; | 44 | int backpos, runlen=0; |
45 | unsigned char value; | 45 | unsigned char value; |
46 | 46 | ||
47 | value = data_in[pos]; | 47 | value = data_in[pos]; |
48 | 48 | ||
49 | cpage_out[outpos++] = data_in[pos++]; | 49 | cpage_out[outpos++] = data_in[pos++]; |
50 | 50 | ||
51 | backpos = positions[value]; | 51 | backpos = positions[value]; |
52 | positions[value]=pos; | 52 | positions[value]=pos; |
53 | 53 | ||
54 | while ((backpos < pos) && (pos < (*sourcelen)) && | 54 | while ((backpos < pos) && (pos < (*sourcelen)) && |
55 | (data_in[pos]==data_in[backpos++]) && (runlen<255)) { | 55 | (data_in[pos]==data_in[backpos++]) && (runlen<255)) { |
56 | pos++; | 56 | pos++; |
@@ -63,12 +63,12 @@ static int jffs2_rtime_compress(unsigned char *data_in, | |||
63 | /* We failed */ | 63 | /* We failed */ |
64 | return -1; | 64 | return -1; |
65 | } | 65 | } |
66 | 66 | ||
67 | /* Tell the caller how much we managed to compress, and how much space it took */ | 67 | /* Tell the caller how much we managed to compress, and how much space it took */ |
68 | *sourcelen = pos; | 68 | *sourcelen = pos; |
69 | *dstlen = outpos; | 69 | *dstlen = outpos; |
70 | return 0; | 70 | return 0; |
71 | } | 71 | } |
72 | 72 | ||
73 | 73 | ||
74 | static int jffs2_rtime_decompress(unsigned char *data_in, | 74 | static int jffs2_rtime_decompress(unsigned char *data_in, |
@@ -79,19 +79,19 @@ static int jffs2_rtime_decompress(unsigned char *data_in, | |||
79 | short positions[256]; | 79 | short positions[256]; |
80 | int outpos = 0; | 80 | int outpos = 0; |
81 | int pos=0; | 81 | int pos=0; |
82 | 82 | ||
83 | memset(positions,0,sizeof(positions)); | 83 | memset(positions,0,sizeof(positions)); |
84 | 84 | ||
85 | while (outpos<destlen) { | 85 | while (outpos<destlen) { |
86 | unsigned char value; | 86 | unsigned char value; |
87 | int backoffs; | 87 | int backoffs; |
88 | int repeat; | 88 | int repeat; |
89 | 89 | ||
90 | value = data_in[pos++]; | 90 | value = data_in[pos++]; |
91 | cpage_out[outpos++] = value; /* first the verbatim copied byte */ | 91 | cpage_out[outpos++] = value; /* first the verbatim copied byte */ |
92 | repeat = data_in[pos++]; | 92 | repeat = data_in[pos++]; |
93 | backoffs = positions[value]; | 93 | backoffs = positions[value]; |
94 | 94 | ||
95 | positions[value]=outpos; | 95 | positions[value]=outpos; |
96 | if (repeat) { | 96 | if (repeat) { |
97 | if (backoffs + repeat >= outpos) { | 97 | if (backoffs + repeat >= outpos) { |
@@ -101,12 +101,12 @@ static int jffs2_rtime_decompress(unsigned char *data_in, | |||
101 | } | 101 | } |
102 | } else { | 102 | } else { |
103 | memcpy(&cpage_out[outpos],&cpage_out[backoffs],repeat); | 103 | memcpy(&cpage_out[outpos],&cpage_out[backoffs],repeat); |
104 | outpos+=repeat; | 104 | outpos+=repeat; |
105 | } | 105 | } |
106 | } | 106 | } |
107 | } | 107 | } |
108 | return 0; | 108 | return 0; |
109 | } | 109 | } |
110 | 110 | ||
111 | static struct jffs2_compressor jffs2_rtime_comp = { | 111 | static struct jffs2_compressor jffs2_rtime_comp = { |
112 | .priority = JFFS2_RTIME_PRIORITY, | 112 | .priority = JFFS2_RTIME_PRIORITY, |