Browse Source

Fix warnings about assigning paramter in util.io

Change-Id: I08bed4275af9ec52aa4d7054067ac82f6a3c9781
tags/v3.0.0.201305080800-m7
Robin Stocker 11 years ago
parent
commit
252b1dd5c2

+ 10
- 10
org.eclipse.jgit/src/org/eclipse/jgit/util/io/AutoCRLFInputStream.java View File

@@ -1,6 +1,6 @@
/*
* Copyright (C) 2012, Robin Rosenberg
* Copyright (C) 2010, Marc Strapetz <marc.strapetz@syntevo.com>
* Copyright (C) 2010, 2013 Marc Strapetz <marc.strapetz@syntevo.com>
* and other copyright owners as documented in the project's IP log.
*
* This program and the accompanying materials are made available
@@ -98,40 +98,40 @@ public class AutoCRLFInputStream extends InputStream {
}

@Override
public int read(byte[] bs, int off, int len) throws IOException {
public int read(byte[] bs, final int off, final int len) throws IOException {
if (len == 0)
return 0;

if (cnt == -1)
return -1;

final int startOff = off;
int i = off;
final int end = off + len;

while (off < end) {
while (i < end) {
if (ptr == cnt && !fillBuffer())
break;

byte b = buf[ptr++];
if (isBinary || b != '\n') {
// Logic for binary files ends here
bs[off++] = last = b;
bs[i++] = last = b;
continue;
}

if (b == '\n') {
if (last == '\r') {
bs[off++] = last = b;
bs[i++] = last = b;
continue;
}
bs[off++] = last = '\r';
bs[i++] = last = '\r';
ptr--;
} else
bs[off++] = last = b;
bs[i++] = last = b;
}
int n = startOff == off ? -1 : off - startOff;
int n = i == off ? -1 : i - off;
if (n > 0)
last = bs[off - 1];
last = bs[i - 1];
return n;
}


+ 6
- 5
org.eclipse.jgit/src/org/eclipse/jgit/util/io/AutoCRLFOutputStream.java View File

@@ -90,12 +90,13 @@ public class AutoCRLFOutputStream extends OutputStream {
}

@Override
public void write(byte[] b, int off, int len) throws IOException {
int overflow = buffer(b, off, len);
public void write(byte[] b, final int startOff, final int startLen)
throws IOException {
final int overflow = buffer(b, startOff, startLen);
if (overflow < 0)
return;
off = off + len - overflow;
len = overflow;
final int off = startOff + startLen - overflow;
final int len = overflow;
if (len == 0)
return;
int lastw = off;
@@ -104,7 +105,7 @@ public class AutoCRLFOutputStream extends OutputStream {
return;
}
for (int i = off; i < off + len; ++i) {
byte c = b[i];
final byte c = b[i];
if (c == '\r') {
buf = '\r';
} else if (c == '\n') {

+ 9
- 9
org.eclipse.jgit/src/org/eclipse/jgit/util/io/EolCanonicalizingInputStream.java View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010, Marc Strapetz <marc.strapetz@syntevo.com>
* Copyright (C) 2010, 2013 Marc Strapetz <marc.strapetz@syntevo.com>
* and other copyright owners as documented in the project's IP log.
*
* This program and the accompanying materials are made available
@@ -91,17 +91,17 @@ public class EolCanonicalizingInputStream extends InputStream {
}

@Override
public int read(byte[] bs, int off, int len) throws IOException {
public int read(byte[] bs, final int off, final int len) throws IOException {
if (len == 0)
return 0;

if (cnt == -1)
return -1;

final int startOff = off;
int i = off;
final int end = off + len;

while (off < end) {
while (i < end) {
if (ptr == cnt && !fillBuffer()) {
break;
}
@@ -109,23 +109,23 @@ public class EolCanonicalizingInputStream extends InputStream {
byte b = buf[ptr++];
if (isBinary || b != '\r') {
// Logic for binary files ends here
bs[off++] = b;
bs[i++] = b;
continue;
}

if (ptr == cnt && !fillBuffer()) {
bs[off++] = '\r';
bs[i++] = '\r';
break;
}

if (buf[ptr] == '\n') {
bs[off++] = '\n';
bs[i++] = '\n';
ptr++;
} else
bs[off++] = '\r';
bs[i++] = '\r';
}

return startOff == off ? -1 : off - startOff;
return i == off ? -1 : i - off;
}

@Override

+ 5
- 4
org.eclipse.jgit/src/org/eclipse/jgit/util/io/TeeInputStream.java View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2010, Google Inc.
* Copyright (C) 2010, 2013 Google Inc.
* and other copyright owners as documented in the project's IP log.
*
* This program and the accompanying materials are made available
@@ -89,11 +89,12 @@ public class TeeInputStream extends InputStream {
}

@Override
public long skip(long cnt) throws IOException {
public long skip(final long count) throws IOException {
long skipped = 0;
byte[] b = skipBuffer();
long cnt = count;
final byte[] b = skipBuffer();
while (0 < cnt) {
int n = src.read(b, 0, (int) Math.min(b.length, cnt));
final int n = src.read(b, 0, (int) Math.min(b.length, cnt));
if (n <= 0)
break;
dst.write(b, 0, n);

+ 13
- 12
org.eclipse.jgit/src/org/eclipse/jgit/util/io/UnionInputStream.java View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2009, Google Inc.
* Copyright (C) 2009, 2013 Google Inc.
* and other copyright owners as documented in the project's IP log.
*
* This program and the accompanying materials are made available
@@ -158,17 +158,18 @@ public class UnionInputStream extends InputStream {
}

@Override
public long skip(long len) throws IOException {
long cnt = 0;
while (0 < len) {
public long skip(final long count) throws IOException {
long skipped = 0;
long cnt = count;
while (0 < cnt) {
final InputStream in = head();
final long n = in.skip(len);
final long n = in.skip(cnt);
if (0 < n) {
cnt += n;
len -= n;
skipped += n;
cnt -= n;

} else if (in == EOF) {
return cnt;
return skipped;

} else {
// Is this stream at EOF? We can't tell from skip alone.
@@ -178,15 +179,15 @@ public class UnionInputStream extends InputStream {
final int r = in.read();
if (r < 0) {
pop();
if (0 < cnt)
if (0 < skipped)
break;
} else {
cnt += 1;
len -= 1;
skipped += 1;
cnt -= 1;
}
}
}
return cnt;
return skipped;
}

@Override

Loading…
Cancel
Save