NOISSUE fix unitialized data warning on Arch Linux
This commit is contained in:
parent
a222c94d34
commit
8108c61745
@ -32,7 +32,7 @@ set(CMAKE_C_STANDARD_REQUIRED true)
|
|||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
include(GenerateExportHeader)
|
include(GenerateExportHeader)
|
||||||
set(CMAKE_CXX_FLAGS " -Wall -pedantic -Werror -D_GLIBCXX_USE_CXX11_ABI=0 ${CMAKE_CXX_FLAGS}")
|
set(CMAKE_CXX_FLAGS " -Wall -pedantic -Werror -D_GLIBCXX_USE_CXX11_ABI=0 -fstack-protector-strong --param=ssp-buffer-size=4 -O3 -D_FORTIFY_SOURCE=2 ${CMAKE_CXX_FLAGS}")
|
||||||
if(UNIX AND APPLE)
|
if(UNIX AND APPLE)
|
||||||
set(CMAKE_CXX_FLAGS " -stdlib=libc++ ${CMAKE_CXX_FLAGS}")
|
set(CMAKE_CXX_FLAGS " -stdlib=libc++ ${CMAKE_CXX_FLAGS}")
|
||||||
endif()
|
endif()
|
||||||
|
@ -59,7 +59,7 @@ QString GetMinecraftJarVersion(QString jarName)
|
|||||||
iter != constants.end(); iter++)
|
iter != constants.end(); iter++)
|
||||||
{
|
{
|
||||||
const java::constant &constant = *iter;
|
const java::constant &constant = *iter;
|
||||||
if (constant.type != java::constant::j_string_data)
|
if (constant.type != java::constant_type_t::j_string_data)
|
||||||
continue;
|
continue;
|
||||||
const std::string &str = constant.str_data;
|
const std::string &str = constant.str_data;
|
||||||
qDebug() << QString::fromStdString(str);
|
qDebug() << QString::fromStdString(str);
|
||||||
|
@ -4,25 +4,46 @@
|
|||||||
|
|
||||||
namespace java
|
namespace java
|
||||||
{
|
{
|
||||||
|
enum class constant_type_t : uint8_t
|
||||||
|
{
|
||||||
|
j_hole = 0, // HACK: this is a hole in the array, because java is crazy
|
||||||
|
j_string_data = 1,
|
||||||
|
j_int = 3,
|
||||||
|
j_float = 4,
|
||||||
|
j_long = 5,
|
||||||
|
j_double = 6,
|
||||||
|
j_class = 7,
|
||||||
|
j_string = 8,
|
||||||
|
j_fieldref = 9,
|
||||||
|
j_methodref = 10,
|
||||||
|
j_interface_methodref = 11,
|
||||||
|
j_nameandtype = 12
|
||||||
|
// FIXME: missing some constant types, see https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.4
|
||||||
|
};
|
||||||
|
|
||||||
|
struct ref_type_t
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Class reference:
|
||||||
|
* an index within the constant pool to a UTF-8 string containing
|
||||||
|
* the fully qualified class name (in internal format)
|
||||||
|
* Used for j_class, j_fieldref, j_methodref and j_interface_methodref
|
||||||
|
*/
|
||||||
|
uint16_t class_idx;
|
||||||
|
// used for j_fieldref, j_methodref and j_interface_methodref
|
||||||
|
uint16_t name_and_type_idx;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct name_and_type_t
|
||||||
|
{
|
||||||
|
uint16_t name_index;
|
||||||
|
uint16_t descriptor_index;
|
||||||
|
};
|
||||||
|
|
||||||
class constant
|
class constant
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum type_t : uint8_t
|
constant_type_t type = constant_type_t::j_hole;
|
||||||
{
|
|
||||||
j_hole = 0, // HACK: this is a hole in the array, because java is crazy
|
|
||||||
j_string_data = 1,
|
|
||||||
j_int = 3,
|
|
||||||
j_float = 4,
|
|
||||||
j_long = 5,
|
|
||||||
j_double = 6,
|
|
||||||
j_class = 7,
|
|
||||||
j_string = 8,
|
|
||||||
j_fieldref = 9,
|
|
||||||
j_methodref = 10,
|
|
||||||
j_interface_methodref = 11,
|
|
||||||
j_nameandtype = 12
|
|
||||||
// FIXME: missing some constant types, see https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.4
|
|
||||||
} type;
|
|
||||||
|
|
||||||
constant(util::membuffer &buf)
|
constant(util::membuffer &buf)
|
||||||
{
|
{
|
||||||
@ -31,27 +52,31 @@ public:
|
|||||||
// load data depending on type
|
// load data depending on type
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case j_float:
|
case constant_type_t::j_float:
|
||||||
case j_int:
|
buf.read_be(data.int_data);
|
||||||
buf.read_be(int_data); // same as float data really
|
|
||||||
break;
|
break;
|
||||||
case j_double:
|
case constant_type_t::j_int:
|
||||||
case j_long:
|
buf.read_be(data.int_data); // same as float data really
|
||||||
buf.read_be(long_data); // same as double
|
|
||||||
break;
|
break;
|
||||||
case j_class:
|
case constant_type_t::j_double:
|
||||||
buf.read_be(ref_type.class_idx);
|
buf.read_be(data.long_data);
|
||||||
break;
|
break;
|
||||||
case j_fieldref:
|
case constant_type_t::j_long:
|
||||||
case j_methodref:
|
buf.read_be(data.long_data); // same as double
|
||||||
case j_interface_methodref:
|
|
||||||
buf.read_be(ref_type.class_idx);
|
|
||||||
buf.read_be(ref_type.name_and_type_idx);
|
|
||||||
break;
|
break;
|
||||||
case j_string:
|
case constant_type_t::j_class:
|
||||||
buf.read_be(index);
|
buf.read_be(data.ref_type.class_idx);
|
||||||
break;
|
break;
|
||||||
case j_string_data:
|
case constant_type_t::j_fieldref:
|
||||||
|
case constant_type_t::j_methodref:
|
||||||
|
case constant_type_t::j_interface_methodref:
|
||||||
|
buf.read_be(data.ref_type.class_idx);
|
||||||
|
buf.read_be(data.ref_type.name_and_type_idx);
|
||||||
|
break;
|
||||||
|
case constant_type_t::j_string:
|
||||||
|
buf.read_be(data.index);
|
||||||
|
break;
|
||||||
|
case constant_type_t::j_string_data:
|
||||||
// HACK HACK: for now, we call these UTF-8 and do no further processing.
|
// HACK HACK: for now, we call these UTF-8 and do no further processing.
|
||||||
// Later, we should do some decoding. It's really modified UTF-8
|
// Later, we should do some decoding. It's really modified UTF-8
|
||||||
// * U+0000 is represented as 0xC0,0x80 invalid character
|
// * U+0000 is represented as 0xC0,0x80 invalid character
|
||||||
@ -59,19 +84,17 @@ public:
|
|||||||
// * characters above U+10000 are encoded like in CESU-8
|
// * characters above U+10000 are encoded like in CESU-8
|
||||||
buf.read_jstr(str_data);
|
buf.read_jstr(str_data);
|
||||||
break;
|
break;
|
||||||
case j_nameandtype:
|
case constant_type_t::j_nameandtype:
|
||||||
buf.read_be(name_and_type.name_index);
|
buf.read_be(data.name_and_type.name_index);
|
||||||
buf.read_be(name_and_type.descriptor_index);
|
buf.read_be(data.name_and_type.descriptor_index);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
// invalid constant type!
|
// invalid constant type!
|
||||||
throw new classfile_exception();
|
throw new classfile_exception();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constant(int)
|
constant(int)
|
||||||
{
|
{
|
||||||
type = j_hole;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string toString()
|
std::string toString()
|
||||||
@ -79,42 +102,42 @@ public:
|
|||||||
std::ostringstream ss;
|
std::ostringstream ss;
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case j_hole:
|
case constant_type_t::j_hole:
|
||||||
ss << "Fake legacy entry";
|
ss << "Fake legacy entry";
|
||||||
break;
|
break;
|
||||||
case j_float:
|
case constant_type_t::j_float:
|
||||||
ss << "Float: " << float_data;
|
ss << "Float: " << data.float_data;
|
||||||
break;
|
break;
|
||||||
case j_double:
|
case constant_type_t::j_double:
|
||||||
ss << "Double: " << double_data;
|
ss << "Double: " << data.double_data;
|
||||||
break;
|
break;
|
||||||
case j_int:
|
case constant_type_t::j_int:
|
||||||
ss << "Int: " << int_data;
|
ss << "Int: " << data.int_data;
|
||||||
break;
|
break;
|
||||||
case j_long:
|
case constant_type_t::j_long:
|
||||||
ss << "Long: " << long_data;
|
ss << "Long: " << data.long_data;
|
||||||
break;
|
break;
|
||||||
case j_string_data:
|
case constant_type_t::j_string_data:
|
||||||
ss << "StrData: " << str_data;
|
ss << "StrData: " << str_data;
|
||||||
break;
|
break;
|
||||||
case j_string:
|
case constant_type_t::j_string:
|
||||||
ss << "Str: " << index;
|
ss << "Str: " << data.index;
|
||||||
break;
|
break;
|
||||||
case j_fieldref:
|
case constant_type_t::j_fieldref:
|
||||||
ss << "FieldRef: " << ref_type.class_idx << " " << ref_type.name_and_type_idx;
|
ss << "FieldRef: " << data.ref_type.class_idx << " " << data.ref_type.name_and_type_idx;
|
||||||
break;
|
break;
|
||||||
case j_methodref:
|
case constant_type_t::j_methodref:
|
||||||
ss << "MethodRef: " << ref_type.class_idx << " " << ref_type.name_and_type_idx;
|
ss << "MethodRef: " << data.ref_type.class_idx << " " << data.ref_type.name_and_type_idx;
|
||||||
break;
|
break;
|
||||||
case j_interface_methodref:
|
case constant_type_t::j_interface_methodref:
|
||||||
ss << "IfMethodRef: " << ref_type.class_idx << " " << ref_type.name_and_type_idx;
|
ss << "IfMethodRef: " << data.ref_type.class_idx << " " << data.ref_type.name_and_type_idx;
|
||||||
break;
|
break;
|
||||||
case j_class:
|
case constant_type_t::j_class:
|
||||||
ss << "Class: " << ref_type.class_idx;
|
ss << "Class: " << data.ref_type.class_idx;
|
||||||
break;
|
break;
|
||||||
case j_nameandtype:
|
case constant_type_t::j_nameandtype:
|
||||||
ss << "NameAndType: " << name_and_type.name_index << " "
|
ss << "NameAndType: " << data.name_and_type.name_index << " "
|
||||||
<< name_and_type.descriptor_index;
|
<< data.name_and_type.descriptor_index;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
ss << "Invalid entry (" << int(type) << ")";
|
ss << "Invalid entry (" << int(type) << ")";
|
||||||
@ -123,24 +146,6 @@ public:
|
|||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ref_type_t
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
* Class reference:
|
|
||||||
* an index within the constant pool to a UTF-8 string containing
|
|
||||||
* the fully qualified class name (in internal format)
|
|
||||||
* Used for j_class, j_fieldref, j_methodref and j_interface_methodref
|
|
||||||
*/
|
|
||||||
uint16_t class_idx;
|
|
||||||
// used for j_fieldref, j_methodref and j_interface_methodref
|
|
||||||
uint16_t name_and_type_idx;
|
|
||||||
};
|
|
||||||
struct name_and_type_t
|
|
||||||
{
|
|
||||||
uint16_t name_index;
|
|
||||||
uint16_t descriptor_index;
|
|
||||||
};
|
|
||||||
|
|
||||||
std::string str_data; /** String data in 'modified utf-8'.*/
|
std::string str_data; /** String data in 'modified utf-8'.*/
|
||||||
|
|
||||||
// store everything here.
|
// store everything here.
|
||||||
@ -153,7 +158,7 @@ public:
|
|||||||
uint16_t index;
|
uint16_t index;
|
||||||
ref_type_t ref_type;
|
ref_type_t ref_type;
|
||||||
name_and_type_t name_and_type;
|
name_and_type_t name_and_type;
|
||||||
};
|
} data = {0};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -184,8 +189,8 @@ public:
|
|||||||
const constant &cnst = constant(buf);
|
const constant &cnst = constant(buf);
|
||||||
constants.push_back(cnst);
|
constants.push_back(cnst);
|
||||||
last_constant = &constants[constants.size() - 1];
|
last_constant = &constants[constants.size() - 1];
|
||||||
if (last_constant->type == constant::j_double ||
|
if (last_constant->type == constant_type_t::j_double ||
|
||||||
last_constant->type == constant::j_long)
|
last_constant->type == constant_type_t::j_long)
|
||||||
{
|
{
|
||||||
// push in a fake constant to preserve indexing
|
// push in a fake constant to preserve indexing
|
||||||
constants.push_back(constant(0));
|
constants.push_back(constant(0));
|
||||||
|
Loading…
Reference in New Issue
Block a user