summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2007-01-05 19:07:24 +0100
committerTobias Klauser <tklauser@xenon.tklauser.home>2007-01-05 19:07:24 +0100
commita388181df16d237c164ddf79cde6aed58dee6a8e (patch)
tree6215eaae723918edcd034d39adc1da66b945430c
parentb356ec8affa09366306c3d93fecc87d3fe1d2f9c (diff)
inotail.c: Make tail_pipe() return ssize_t
read() returns ssize_t and we were casting it to signed int which might be smaller on some architectures.
-rw-r--r--inotail.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/inotail.c b/inotail.c
index 26092d3..783ac3b 100644
--- a/inotail.c
+++ b/inotail.c
@@ -196,9 +196,9 @@ static off_t bytes_to_offset(struct file_struct *f, unsigned int n_bytes)
return (from_begin ? ((off_t) n_bytes - 1) : (f->st_size - (off_t) n_bytes));
}
-static int tail_pipe(struct file_struct *f)
+static ssize_t tail_pipe(struct file_struct *f)
{
- int rc;
+ ssize_t rc;
char buf[BUFFER_SIZE];
if (verbose)
n (assuming multiply by 9 can be done by an "lea" instruction): x ^= *input++; y ^= x; x = ROL(x, K1); x += y; y = ROL(y, K2); y *= 9; Not only is this reversible, two consecutive rounds are reversible: if you are given the initial and final states, but not the intermediate state, it is possible to compute both input words. This means that at least 3 words of input are required to create a collision. (It also has the property, used by hash_name() to avoid a branch, that it hashes all-zero to all-zero.) The rotate constants K1 and K2 were found by experiment. The search took a sample of random initial states (I used 1023) and considered the effect of flipping each of the 64 input bits on each of the 128 output bits two rounds later. Each of the 8192 pairs can be considered a biased coin, and adding up the Shannon entropy of all of them produces a score. The best-scoring shifts also did well in other tests (flipping bits in y, trying 3 or 4 rounds of mixing, flipping all 64*63/2 pairs of input bits), so the choice was made with the additional constraint that the sum of the shifts is odd and not too close to the word size. The final state is then folded into a 32-bit hash value by a less carefully optimized multiply-based scheme. This also has to be fast, as pathname components tend to be short (the most common case is one iteration!), but there's some room for latency, as there is a fair bit of intervening logic before the hash value is used for anything. (Performance verified with "bonnie++ -s 0 -n 1536:-2" on tmpfs. I need a better benchmark; the numbers seem to show a slight dip in performance between 4.6.0 and this patch, but they're too noisy to quote.) Special thanks to Bruce fields for diligent testing which uncovered a nasty fencepost error in an earlier version of this patch. [checkpatch.pl formatting complaints noted and respectfully disagreed with.] Signed-off-by: George Spelvin <linux@sciencehorizons.net> Tested-by: J. Bruce Fields <bfields@redhat.com>
Diffstat