|
|
8ba7a7 |
# HG changeset patch
|
|
|
8ba7a7 |
# User mikael
|
|
|
b8989a |
# Date 1426870964 25200
|
|
|
b8989a |
# Fri Mar 20 10:02:44 2015 -0700
|
|
|
b8989a |
# Node ID ee13ce369705a700b867f8c77423580b7b22cc13
|
|
|
b8989a |
# Parent 7847ccfb240b35ed0dd328f0404b713b20e0905a
|
|
|
b8989a |
8074839: Resolve disabled warnings for libunpack and the unpack200 binary
|
|
|
8ba7a7 |
Reviewed-by: dholmes, ksrini
|
|
|
8ba7a7 |
|
|
|
b8989a |
diff --git openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/bytes.h openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/bytes.h
|
|
|
b8989a |
--- openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/bytes.h
|
|
|
b8989a |
+++ openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/bytes.h
|
|
|
8ba7a7 |
@@ -63,7 +63,7 @@
|
|
|
8ba7a7 |
bytes res;
|
|
|
8ba7a7 |
res.ptr = ptr + beg;
|
|
|
8ba7a7 |
res.len = end - beg;
|
|
|
8ba7a7 |
- assert(res.len == 0 || inBounds(res.ptr) && inBounds(res.limit()-1));
|
|
|
8ba7a7 |
+ assert(res.len == 0 || (inBounds(res.ptr) && inBounds(res.limit()-1)));
|
|
|
8ba7a7 |
return res;
|
|
|
8ba7a7 |
}
|
|
|
8ba7a7 |
// building C strings inside byte buffers:
|
|
|
b8989a |
diff --git openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/jni.cpp openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/jni.cpp
|
|
|
b8989a |
--- openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/jni.cpp
|
|
|
b8989a |
+++ openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/jni.cpp
|
|
|
8ba7a7 |
@@ -292,7 +292,7 @@
|
|
|
8ba7a7 |
|
|
|
8ba7a7 |
if (uPtr->aborting()) {
|
|
|
8ba7a7 |
THROW_IOE(uPtr->get_abort_message());
|
|
|
8ba7a7 |
- return false;
|
|
|
8ba7a7 |
+ return null;
|
|
|
8ba7a7 |
}
|
|
|
8ba7a7 |
|
|
|
8ba7a7 |
// We have fetched all the files.
|
|
|
8ba7a7 |
@@ -310,7 +310,7 @@
|
|
|
8ba7a7 |
JNIEXPORT jlong JNICALL
|
|
|
8ba7a7 |
Java_com_sun_java_util_jar_pack_NativeUnpack_finish(JNIEnv *env, jobject pObj) {
|
|
|
8ba7a7 |
unpacker* uPtr = get_unpacker(env, pObj, false);
|
|
|
8ba7a7 |
- CHECK_EXCEPTION_RETURN_VALUE(uPtr, NULL);
|
|
|
8ba7a7 |
+ CHECK_EXCEPTION_RETURN_VALUE(uPtr, 0);
|
|
|
8ba7a7 |
size_t consumed = uPtr->input_consumed();
|
|
|
8ba7a7 |
free_unpacker(env, pObj, uPtr);
|
|
|
8ba7a7 |
return consumed;
|
|
|
8ba7a7 |
@@ -320,6 +320,7 @@
|
|
|
8ba7a7 |
Java_com_sun_java_util_jar_pack_NativeUnpack_setOption(JNIEnv *env, jobject pObj,
|
|
|
8ba7a7 |
jstring pProp, jstring pValue) {
|
|
|
8ba7a7 |
unpacker* uPtr = get_unpacker(env, pObj);
|
|
|
8ba7a7 |
+ CHECK_EXCEPTION_RETURN_VALUE(uPtr, false);
|
|
|
8ba7a7 |
const char* prop = env->GetStringUTFChars(pProp, JNI_FALSE);
|
|
|
8ba7a7 |
CHECK_EXCEPTION_RETURN_VALUE(prop, false);
|
|
|
8ba7a7 |
const char* value = env->GetStringUTFChars(pValue, JNI_FALSE);
|
|
|
b8989a |
diff --git openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/main.cpp openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/main.cpp
|
|
|
b8989a |
--- openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/main.cpp
|
|
|
b8989a |
+++ openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/main.cpp
|
|
|
b8989a |
@@ -142,31 +142,28 @@
|
|
|
8ba7a7 |
return progname;
|
|
|
8ba7a7 |
}
|
|
|
8ba7a7 |
|
|
|
8ba7a7 |
-static const char* usage_lines[] = {
|
|
|
8ba7a7 |
- "Usage: %s [-opt... | --option=value]... x.pack[.gz] y.jar\n",
|
|
|
8ba7a7 |
- "\n",
|
|
|
8ba7a7 |
- "Unpacking Options\n",
|
|
|
8ba7a7 |
- " -H{h}, --deflate-hint={h} override transmitted deflate hint: true, false, or keep (default)\n",
|
|
|
8ba7a7 |
- " -r, --remove-pack-file remove input file after unpacking\n",
|
|
|
8ba7a7 |
- " -v, --verbose increase program verbosity\n",
|
|
|
8ba7a7 |
- " -q, --quiet set verbosity to lowest level\n",
|
|
|
8ba7a7 |
- " -l{F}, --log-file={F} output to the given log file, or '-' for standard output (default)\n",
|
|
|
8ba7a7 |
- " -?, -h, --help print this message\n",
|
|
|
8ba7a7 |
- " -V, --version print program version\n",
|
|
|
8ba7a7 |
- " -J{X} Java VM argument (ignored)\n",
|
|
|
8ba7a7 |
- null
|
|
|
8ba7a7 |
-};
|
|
|
8ba7a7 |
+#define USAGE_HEADER "Usage: %s [-opt... | --option=value]... x.pack[.gz] y.jar\n"
|
|
|
8ba7a7 |
+#define USAGE_OPTIONS \
|
|
|
8ba7a7 |
+ "\n" \
|
|
|
8ba7a7 |
+ "Unpacking Options\n" \
|
|
|
8ba7a7 |
+ " -H{h}, --deflate-hint={h} override transmitted deflate hint: true, false, or keep (default)\n" \
|
|
|
8ba7a7 |
+ " -r, --remove-pack-file remove input file after unpacking\n" \
|
|
|
8ba7a7 |
+ " -v, --verbose increase program verbosity\n" \
|
|
|
8ba7a7 |
+ " -q, --quiet set verbosity to lowest level\n" \
|
|
|
8ba7a7 |
+ " -l{F}, --log-file={F} output to the given log file, or '-' for standard output (default)\n" \
|
|
|
8ba7a7 |
+ " -?, -h, --help print this message\n" \
|
|
|
8ba7a7 |
+ " -V, --version print program version\n" \
|
|
|
8ba7a7 |
+ " -J{X} Java VM argument (ignored)\n"
|
|
|
8ba7a7 |
|
|
|
8ba7a7 |
static void usage(unpacker* u, const char* progname, bool full = false) {
|
|
|
8ba7a7 |
// WinMain does not set argv[0] to the progrname
|
|
|
8ba7a7 |
progname = (progname != null) ? nbasename(progname) : "unpack200";
|
|
|
8ba7a7 |
- for (int i = 0; usage_lines[i] != null; i++) {
|
|
|
8ba7a7 |
- fprintf(u->errstrm, usage_lines[i], progname);
|
|
|
8ba7a7 |
- if (!full) {
|
|
|
8ba7a7 |
- fprintf(u->errstrm,
|
|
|
8ba7a7 |
- "(For more information, run %s --help .)\n", progname);
|
|
|
8ba7a7 |
- break;
|
|
|
8ba7a7 |
- }
|
|
|
8ba7a7 |
+
|
|
|
8ba7a7 |
+ fprintf(u->errstrm, USAGE_HEADER, progname);
|
|
|
8ba7a7 |
+ if (full) {
|
|
|
8ba7a7 |
+ fprintf(u->errstrm, USAGE_OPTIONS);
|
|
|
8ba7a7 |
+ } else {
|
|
|
8ba7a7 |
+ fprintf(u->errstrm, "(For more information, run %s --help .)\n", progname);
|
|
|
8ba7a7 |
}
|
|
|
8ba7a7 |
}
|
|
|
8ba7a7 |
|
|
|
b8989a |
diff --git openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.cpp openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.cpp
|
|
|
b8989a |
--- openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.cpp
|
|
|
b8989a |
+++ openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.cpp
|
|
|
8ba7a7 |
@@ -222,9 +222,9 @@
|
|
|
8ba7a7 |
}
|
|
|
8ba7a7 |
|
|
|
8ba7a7 |
#ifdef PRODUCT
|
|
|
8ba7a7 |
- char* string() { return 0; }
|
|
|
8ba7a7 |
+ const char* string() { return NULL; }
|
|
|
8ba7a7 |
#else
|
|
|
8ba7a7 |
- char* string(); // see far below
|
|
|
8ba7a7 |
+ const char* string(); // see far below
|
|
|
8ba7a7 |
#endif
|
|
|
8ba7a7 |
};
|
|
|
8ba7a7 |
|
|
|
8ba7a7 |
@@ -715,13 +715,13 @@
|
|
|
8ba7a7 |
// Now we can size the whole archive.
|
|
|
8ba7a7 |
// Read everything else into a mega-buffer.
|
|
|
8ba7a7 |
rp = hdr.rp;
|
|
|
8ba7a7 |
- int header_size_0 = (int)(rp - input.base()); // used-up header (4byte + 3int)
|
|
|
8ba7a7 |
- int header_size_1 = (int)(rplimit - rp); // buffered unused initial fragment
|
|
|
8ba7a7 |
- int header_size = header_size_0+header_size_1;
|
|
|
8ba7a7 |
+ size_t header_size_0 = (rp - input.base()); // used-up header (4byte + 3int)
|
|
|
8ba7a7 |
+ size_t header_size_1 = (rplimit - rp); // buffered unused initial fragment
|
|
|
8ba7a7 |
+ size_t header_size = header_size_0 + header_size_1;
|
|
|
8ba7a7 |
unsized_bytes_read = header_size_0;
|
|
|
8ba7a7 |
CHECK;
|
|
|
8ba7a7 |
if (foreign_buf) {
|
|
|
8ba7a7 |
- if (archive_size > (size_t)header_size_1) {
|
|
|
8ba7a7 |
+ if (archive_size > header_size_1) {
|
|
|
8ba7a7 |
abort("EOF reading fixed input buffer");
|
|
|
8ba7a7 |
return;
|
|
|
8ba7a7 |
}
|
|
|
8ba7a7 |
@@ -735,7 +735,7 @@
|
|
|
8ba7a7 |
return;
|
|
|
8ba7a7 |
}
|
|
|
8ba7a7 |
input.set(U_NEW(byte, add_size(header_size_0, archive_size, C_SLOP)),
|
|
|
8ba7a7 |
- (size_t) header_size_0 + archive_size);
|
|
|
8ba7a7 |
+ header_size_0 + archive_size);
|
|
|
8ba7a7 |
CHECK;
|
|
|
8ba7a7 |
assert(input.limit()[0] == 0);
|
|
|
8ba7a7 |
// Move all the bytes we read initially into the real buffer.
|
|
|
8ba7a7 |
@@ -958,13 +958,13 @@
|
|
|
8ba7a7 |
nentries = next_entry;
|
|
|
8ba7a7 |
|
|
|
8ba7a7 |
// place a limit on future CP growth:
|
|
|
8ba7a7 |
- int generous = 0;
|
|
|
8ba7a7 |
+ size_t generous = 0;
|
|
|
8ba7a7 |
generous = add_size(generous, u->ic_count); // implicit name
|
|
|
8ba7a7 |
generous = add_size(generous, u->ic_count); // outer
|
|
|
8ba7a7 |
generous = add_size(generous, u->ic_count); // outer.utf8
|
|
|
8ba7a7 |
generous = add_size(generous, 40); // WKUs, misc
|
|
|
8ba7a7 |
generous = add_size(generous, u->class_count); // implicit SourceFile strings
|
|
|
8ba7a7 |
- maxentries = add_size(nentries, generous);
|
|
|
8ba7a7 |
+ maxentries = (uint)add_size(nentries, generous);
|
|
|
8ba7a7 |
|
|
|
8ba7a7 |
// Note that this CP does not include "empty" entries
|
|
|
8ba7a7 |
// for longs and doubles. Those are introduced when
|
|
|
8ba7a7 |
@@ -982,8 +982,9 @@
|
|
|
8ba7a7 |
}
|
|
|
8ba7a7 |
|
|
|
8ba7a7 |
// Initialize *all* our entries once
|
|
|
8ba7a7 |
- for (int i = 0 ; i < maxentries ; i++)
|
|
|
8ba7a7 |
+ for (uint i = 0 ; i < maxentries ; i++) {
|
|
|
8ba7a7 |
entries[i].outputIndex = REQUESTED_NONE;
|
|
|
8ba7a7 |
+ }
|
|
|
8ba7a7 |
|
|
|
8ba7a7 |
initGroupIndexes();
|
|
|
8ba7a7 |
// Initialize hashTab to a generous power-of-two size.
|
|
|
b8989a |
@@ -3677,21 +3678,22 @@
|
|
|
8ba7a7 |
|
|
|
8ba7a7 |
unpacker* debug_u;
|
|
|
8ba7a7 |
|
|
|
8ba7a7 |
-static bytes& getbuf(int len) { // for debugging only!
|
|
|
8ba7a7 |
+static bytes& getbuf(size_t len) { // for debugging only!
|
|
|
8ba7a7 |
static int bn = 0;
|
|
|
8ba7a7 |
static bytes bufs[8];
|
|
|
8ba7a7 |
bytes& buf = bufs[bn++ & 7];
|
|
|
8ba7a7 |
- while ((int)buf.len < len+10)
|
|
|
8ba7a7 |
+ while (buf.len < len + 10) {
|
|
|
8ba7a7 |
buf.realloc(buf.len ? buf.len * 2 : 1000);
|
|
|
8ba7a7 |
+ }
|
|
|
8ba7a7 |
buf.ptr[0] = 0; // for the sake of strcat
|
|
|
8ba7a7 |
return buf;
|
|
|
8ba7a7 |
}
|
|
|
8ba7a7 |
|
|
|
8ba7a7 |
-char* entry::string() {
|
|
|
8ba7a7 |
+const char* entry::string() {
|
|
|
8ba7a7 |
bytes buf;
|
|
|
8ba7a7 |
switch (tag) {
|
|
|
8ba7a7 |
case CONSTANT_None:
|
|
|
8ba7a7 |
- return (char*)"<empty>";
|
|
|
8ba7a7 |
+ return "<empty>";
|
|
|
8ba7a7 |
case CONSTANT_Signature:
|
|
|
8ba7a7 |
if (value.b.ptr == null)
|
|
|
8ba7a7 |
return ref(0)->string();
|
|
|
b8989a |
@@ -3711,26 +3713,28 @@
|
|
|
8ba7a7 |
break;
|
|
|
8ba7a7 |
default:
|
|
|
8ba7a7 |
if (nrefs == 0) {
|
|
|
8ba7a7 |
- buf = getbuf(20);
|
|
|
8ba7a7 |
- sprintf((char*)buf.ptr, TAG_NAME[tag]);
|
|
|
8ba7a7 |
+ return TAG_NAME[tag];
|
|
|
8ba7a7 |
} else if (nrefs == 1) {
|
|
|
8ba7a7 |
return refs[0]->string();
|
|
|
8ba7a7 |
} else {
|
|
|
8ba7a7 |
- char* s1 = refs[0]->string();
|
|
|
8ba7a7 |
- char* s2 = refs[1]->string();
|
|
|
8ba7a7 |
- buf = getbuf((int)strlen(s1) + 1 + (int)strlen(s2) + 4 + 1);
|
|
|
8ba7a7 |
+ const char* s1 = refs[0]->string();
|
|
|
8ba7a7 |
+ const char* s2 = refs[1]->string();
|
|
|
8ba7a7 |
+ buf = getbuf(strlen(s1) + 1 + strlen(s2) + 4 + 1);
|
|
|
8ba7a7 |
buf.strcat(s1).strcat(" ").strcat(s2);
|
|
|
8ba7a7 |
if (nrefs > 2) buf.strcat(" ...");
|
|
|
8ba7a7 |
}
|
|
|
8ba7a7 |
}
|
|
|
8ba7a7 |
- return (char*)buf.ptr;
|
|
|
8ba7a7 |
+ return (const char*)buf.ptr;
|
|
|
8ba7a7 |
}
|
|
|
8ba7a7 |
|
|
|
8ba7a7 |
void print_cp_entry(int i) {
|
|
|
8ba7a7 |
entry& e = debug_u->cp.entries[i];
|
|
|
8ba7a7 |
- char buf[30];
|
|
|
8ba7a7 |
- sprintf(buf, ((uint)e.tag < CONSTANT_Limit)? TAG_NAME[e.tag]: "%d", e.tag);
|
|
|
8ba7a7 |
- printf(" %d\t%s %s\n", i, buf, e.string());
|
|
|
8ba7a7 |
+
|
|
|
8ba7a7 |
+ if ((uint)e.tag < CONSTANT_Limit) {
|
|
|
8ba7a7 |
+ printf(" %d\t%s %s\n", i, TAG_NAME[e.tag], e.string());
|
|
|
8ba7a7 |
+ } else {
|
|
|
8ba7a7 |
+ printf(" %d\t%d %s\n", i, e.tag, e.string());
|
|
|
8ba7a7 |
+ }
|
|
|
8ba7a7 |
}
|
|
|
8ba7a7 |
|
|
|
8ba7a7 |
void print_cp_entries(int beg, int end) {
|
|
|
b8989a |
diff --git openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.h openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.h
|
|
|
b8989a |
--- openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.h
|
|
|
b8989a |
+++ openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.h
|
|
|
b8989a |
@@ -209,7 +209,7 @@
|
|
|
8ba7a7 |
byte* rp; // read pointer (< rplimit <= input.limit())
|
|
|
8ba7a7 |
byte* rplimit; // how much of the input block has been read?
|
|
|
8ba7a7 |
julong bytes_read;
|
|
|
8ba7a7 |
- int unsized_bytes_read;
|
|
|
8ba7a7 |
+ size_t unsized_bytes_read;
|
|
|
8ba7a7 |
|
|
|
8ba7a7 |
// callback to read at least one byte, up to available input
|
|
|
8ba7a7 |
typedef jlong (*read_input_fn_t)(unpacker* self, void* buf, jlong minlen, jlong maxlen);
|
|
|
b8989a |
diff --git openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/utils.cpp openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/utils.cpp
|
|
|
b8989a |
--- openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/utils.cpp
|
|
|
b8989a |
+++ openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/utils.cpp
|
|
|
8ba7a7 |
@@ -81,7 +81,7 @@
|
|
|
8ba7a7 |
int assert_failed(const char* p) {
|
|
|
8ba7a7 |
char message[1<<12];
|
|
|
8ba7a7 |
sprintf(message, "@assert failed: %s\n", p);
|
|
|
8ba7a7 |
- fprintf(stdout, 1+message);
|
|
|
8ba7a7 |
+ fprintf(stdout, "%s", 1+message);
|
|
|
8ba7a7 |
breakpoint();
|
|
|
8ba7a7 |
unpack_abort(message);
|
|
|
8ba7a7 |
return 0;
|
|
|
b8989a |
diff --git openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp
|
|
|
b8989a |
--- openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp
|
|
|
b8989a |
+++ openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/zip.cpp
|
|
|
8ba7a7 |
@@ -84,7 +84,7 @@
|
|
|
8ba7a7 |
}
|
|
|
8ba7a7 |
|
|
|
8ba7a7 |
// Write data to the ZIP output stream.
|
|
|
8ba7a7 |
-void jar::write_data(void* buff, int len) {
|
|
|
8ba7a7 |
+void jar::write_data(void* buff, size_t len) {
|
|
|
8ba7a7 |
while (len > 0) {
|
|
|
8ba7a7 |
int rc = (int)fwrite(buff, 1, len, jarfp);
|
|
|
8ba7a7 |
if (rc <= 0) {
|
|
|
8ba7a7 |
@@ -323,12 +323,12 @@
|
|
|
8ba7a7 |
// Total number of disks (int)
|
|
|
8ba7a7 |
header64[36] = (ushort)SWAP_BYTES(1);
|
|
|
8ba7a7 |
header64[37] = 0;
|
|
|
8ba7a7 |
- write_data(header64, (int)sizeof(header64));
|
|
|
8ba7a7 |
+ write_data(header64, sizeof(header64));
|
|
|
8ba7a7 |
}
|
|
|
8ba7a7 |
|
|
|
8ba7a7 |
// Write the End of Central Directory structure.
|
|
|
8ba7a7 |
PRINTCR((2, "end-of-directory at %d\n", output_file_offset));
|
|
|
8ba7a7 |
- write_data(header, (int)sizeof(header));
|
|
|
8ba7a7 |
+ write_data(header, sizeof(header));
|
|
|
8ba7a7 |
|
|
|
8ba7a7 |
PRINTCR((2, "writing zip comment\n"));
|
|
|
8ba7a7 |
// Write the comment.
|
|
|
b8989a |
diff --git openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/zip.h openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/zip.h
|
|
|
b8989a |
--- openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/zip.h
|
|
|
b8989a |
+++ openjdk/jdk/src/share/native/com/sun/java/util/jar/pack/zip.h
|
|
|
8ba7a7 |
@@ -68,8 +68,8 @@
|
|
|
8ba7a7 |
}
|
|
|
8ba7a7 |
|
|
|
8ba7a7 |
// Private Methods
|
|
|
8ba7a7 |
- void write_data(void* ptr, int len);
|
|
|
8ba7a7 |
- void write_data(bytes& b) { write_data(b.ptr, (int)b.len); }
|
|
|
8ba7a7 |
+ void write_data(void* ptr, size_t len);
|
|
|
8ba7a7 |
+ void write_data(bytes& b) { write_data(b.ptr, b.len); }
|
|
|
8ba7a7 |
void add_to_jar_directory(const char* fname, bool store, int modtime,
|
|
|
8ba7a7 |
int len, int clen, uLong crc);
|
|
|
8ba7a7 |
void write_jar_header(const char* fname, bool store, int modtime,
|