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