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,11 +4,8 @@
|
|||||||
|
|
||||||
namespace java
|
namespace java
|
||||||
{
|
{
|
||||||
class constant
|
enum class constant_type_t : uint8_t
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
enum type_t : uint8_t
|
|
||||||
{
|
|
||||||
j_hole = 0, // HACK: this is a hole in the array, because java is crazy
|
j_hole = 0, // HACK: this is a hole in the array, because java is crazy
|
||||||
j_string_data = 1,
|
j_string_data = 1,
|
||||||
j_int = 3,
|
j_int = 3,
|
||||||
@ -22,109 +19,10 @@ public:
|
|||||||
j_interface_methodref = 11,
|
j_interface_methodref = 11,
|
||||||
j_nameandtype = 12
|
j_nameandtype = 12
|
||||||
// FIXME: missing some constant types, see https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.4
|
// 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)
|
struct ref_type_t
|
||||||
{
|
{
|
||||||
buf.read(type);
|
|
||||||
|
|
||||||
// load data depending on type
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case j_float:
|
|
||||||
case j_int:
|
|
||||||
buf.read_be(int_data); // same as float data really
|
|
||||||
break;
|
|
||||||
case j_double:
|
|
||||||
case j_long:
|
|
||||||
buf.read_be(long_data); // same as double
|
|
||||||
break;
|
|
||||||
case j_class:
|
|
||||||
buf.read_be(ref_type.class_idx);
|
|
||||||
break;
|
|
||||||
case j_fieldref:
|
|
||||||
case j_methodref:
|
|
||||||
case j_interface_methodref:
|
|
||||||
buf.read_be(ref_type.class_idx);
|
|
||||||
buf.read_be(ref_type.name_and_type_idx);
|
|
||||||
break;
|
|
||||||
case j_string:
|
|
||||||
buf.read_be(index);
|
|
||||||
break;
|
|
||||||
case j_string_data:
|
|
||||||
// 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
|
|
||||||
// * U+0000 is represented as 0xC0,0x80 invalid character
|
|
||||||
// * any single zero byte ends the string
|
|
||||||
// * characters above U+10000 are encoded like in CESU-8
|
|
||||||
buf.read_jstr(str_data);
|
|
||||||
break;
|
|
||||||
case j_nameandtype:
|
|
||||||
buf.read_be(name_and_type.name_index);
|
|
||||||
buf.read_be(name_and_type.descriptor_index);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
// invalid constant type!
|
|
||||||
throw new classfile_exception();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
constant(int)
|
|
||||||
{
|
|
||||||
type = j_hole;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string toString()
|
|
||||||
{
|
|
||||||
std::ostringstream ss;
|
|
||||||
switch (type)
|
|
||||||
{
|
|
||||||
case j_hole:
|
|
||||||
ss << "Fake legacy entry";
|
|
||||||
break;
|
|
||||||
case j_float:
|
|
||||||
ss << "Float: " << float_data;
|
|
||||||
break;
|
|
||||||
case j_double:
|
|
||||||
ss << "Double: " << double_data;
|
|
||||||
break;
|
|
||||||
case j_int:
|
|
||||||
ss << "Int: " << int_data;
|
|
||||||
break;
|
|
||||||
case j_long:
|
|
||||||
ss << "Long: " << long_data;
|
|
||||||
break;
|
|
||||||
case j_string_data:
|
|
||||||
ss << "StrData: " << str_data;
|
|
||||||
break;
|
|
||||||
case j_string:
|
|
||||||
ss << "Str: " << index;
|
|
||||||
break;
|
|
||||||
case j_fieldref:
|
|
||||||
ss << "FieldRef: " << ref_type.class_idx << " " << ref_type.name_and_type_idx;
|
|
||||||
break;
|
|
||||||
case j_methodref:
|
|
||||||
ss << "MethodRef: " << ref_type.class_idx << " " << ref_type.name_and_type_idx;
|
|
||||||
break;
|
|
||||||
case j_interface_methodref:
|
|
||||||
ss << "IfMethodRef: " << ref_type.class_idx << " " << ref_type.name_and_type_idx;
|
|
||||||
break;
|
|
||||||
case j_class:
|
|
||||||
ss << "Class: " << ref_type.class_idx;
|
|
||||||
break;
|
|
||||||
case j_nameandtype:
|
|
||||||
ss << "NameAndType: " << name_and_type.name_index << " "
|
|
||||||
<< name_and_type.descriptor_index;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
ss << "Invalid entry (" << int(type) << ")";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return ss.str();
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ref_type_t
|
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Class reference:
|
* Class reference:
|
||||||
* an index within the constant pool to a UTF-8 string containing
|
* an index within the constant pool to a UTF-8 string containing
|
||||||
@ -134,12 +32,119 @@ public:
|
|||||||
uint16_t class_idx;
|
uint16_t class_idx;
|
||||||
// used for j_fieldref, j_methodref and j_interface_methodref
|
// used for j_fieldref, j_methodref and j_interface_methodref
|
||||||
uint16_t name_and_type_idx;
|
uint16_t name_and_type_idx;
|
||||||
};
|
};
|
||||||
struct name_and_type_t
|
|
||||||
{
|
struct name_and_type_t
|
||||||
|
{
|
||||||
uint16_t name_index;
|
uint16_t name_index;
|
||||||
uint16_t descriptor_index;
|
uint16_t descriptor_index;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class constant
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
constant_type_t type = constant_type_t::j_hole;
|
||||||
|
|
||||||
|
constant(util::membuffer &buf)
|
||||||
|
{
|
||||||
|
buf.read(type);
|
||||||
|
|
||||||
|
// load data depending on type
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case constant_type_t::j_float:
|
||||||
|
buf.read_be(data.int_data);
|
||||||
|
break;
|
||||||
|
case constant_type_t::j_int:
|
||||||
|
buf.read_be(data.int_data); // same as float data really
|
||||||
|
break;
|
||||||
|
case constant_type_t::j_double:
|
||||||
|
buf.read_be(data.long_data);
|
||||||
|
break;
|
||||||
|
case constant_type_t::j_long:
|
||||||
|
buf.read_be(data.long_data); // same as double
|
||||||
|
break;
|
||||||
|
case constant_type_t::j_class:
|
||||||
|
buf.read_be(data.ref_type.class_idx);
|
||||||
|
break;
|
||||||
|
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.
|
||||||
|
// Later, we should do some decoding. It's really modified UTF-8
|
||||||
|
// * U+0000 is represented as 0xC0,0x80 invalid character
|
||||||
|
// * any single zero byte ends the string
|
||||||
|
// * characters above U+10000 are encoded like in CESU-8
|
||||||
|
buf.read_jstr(str_data);
|
||||||
|
break;
|
||||||
|
case constant_type_t::j_nameandtype:
|
||||||
|
buf.read_be(data.name_and_type.name_index);
|
||||||
|
buf.read_be(data.name_and_type.descriptor_index);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// invalid constant type!
|
||||||
|
throw new classfile_exception();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
constant(int)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string toString()
|
||||||
|
{
|
||||||
|
std::ostringstream ss;
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case constant_type_t::j_hole:
|
||||||
|
ss << "Fake legacy entry";
|
||||||
|
break;
|
||||||
|
case constant_type_t::j_float:
|
||||||
|
ss << "Float: " << data.float_data;
|
||||||
|
break;
|
||||||
|
case constant_type_t::j_double:
|
||||||
|
ss << "Double: " << data.double_data;
|
||||||
|
break;
|
||||||
|
case constant_type_t::j_int:
|
||||||
|
ss << "Int: " << data.int_data;
|
||||||
|
break;
|
||||||
|
case constant_type_t::j_long:
|
||||||
|
ss << "Long: " << data.long_data;
|
||||||
|
break;
|
||||||
|
case constant_type_t::j_string_data:
|
||||||
|
ss << "StrData: " << str_data;
|
||||||
|
break;
|
||||||
|
case constant_type_t::j_string:
|
||||||
|
ss << "Str: " << data.index;
|
||||||
|
break;
|
||||||
|
case constant_type_t::j_fieldref:
|
||||||
|
ss << "FieldRef: " << data.ref_type.class_idx << " " << data.ref_type.name_and_type_idx;
|
||||||
|
break;
|
||||||
|
case constant_type_t::j_methodref:
|
||||||
|
ss << "MethodRef: " << data.ref_type.class_idx << " " << data.ref_type.name_and_type_idx;
|
||||||
|
break;
|
||||||
|
case constant_type_t::j_interface_methodref:
|
||||||
|
ss << "IfMethodRef: " << data.ref_type.class_idx << " " << data.ref_type.name_and_type_idx;
|
||||||
|
break;
|
||||||
|
case constant_type_t::j_class:
|
||||||
|
ss << "Class: " << data.ref_type.class_idx;
|
||||||
|
break;
|
||||||
|
case constant_type_t::j_nameandtype:
|
||||||
|
ss << "NameAndType: " << data.name_and_type.name_index << " "
|
||||||
|
<< data.name_and_type.descriptor_index;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ss << "Invalid entry (" << int(type) << ")";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return ss.str();
|
||||||
|
}
|
||||||
|
|
||||||
std::string str_data; /** String data in 'modified utf-8'.*/
|
std::string str_data; /** String data in 'modified utf-8'.*/
|
||||||
|
|
||||||
@ -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