Skip to content

Commit

Permalink
Actually fix analysis lint
Browse files Browse the repository at this point in the history
  • Loading branch information
VisualEhrmanntraut committed Aug 12, 2024
1 parent 4bd8300 commit b74ac1c
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 19 deletions.
3 changes: 2 additions & 1 deletion NootedRed/HWLibs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ using t_createFirmware = void *(*)(const void *data, UInt32 size, UInt32 ipVersi
using t_putFirmware = bool (*)(void *that, UInt32 deviceType, void *fw);

class X5000HWLibs {
public:
static X5000HWLibs *callback;

public:
void init();
bool processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t slide, size_t size);

Expand Down
31 changes: 17 additions & 14 deletions NootedRed/NRed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,28 +144,22 @@ void NRed::processPatcher(KernelPatcher &patcher) {
x6000fb.registerDispMaxBrightnessNotif();
}

static OSObject *getDriverXMLForBundle(const char *bundleIdentifier) {
static const char *getDriverXMLForBundle(const char *bundleIdentifier, size_t *len) {
const auto identifierLen = strlen(bundleIdentifier);
const auto totalLen = identifierLen + 5;
auto *filename = new char[totalLen];
memcpy(filename, bundleIdentifier, identifierLen);
strlcat(filename, ".xml", totalLen);

const auto &driversXML = getFWByName(filename);
delete[] filename;

auto *dataNull = new char[driversXML.length + 1];
*len = driversXML.length + 1;
auto *dataNull = new char[*len];
memcpy(dataNull, driversXML.data, driversXML.length);
dataNull[driversXML.length] = 0;

OSString *errStr = nullptr;
auto *dataUnserialized = OSUnserializeXML(dataNull, driversXML.length + 1, &errStr);
delete[] dataNull;

PANIC_COND(dataUnserialized == nullptr, "NRed", "Failed to unserialize %s: %s", filename,
errStr ? errStr->getCStringNoCopy() : "(nil)");

delete[] filename;
return dataUnserialized;
return dataNull;
}

static const char *DriverBundleIdentifiers[] = {
Expand Down Expand Up @@ -209,13 +203,22 @@ bool NRed::wrapAddDrivers(void *that, OSArray *array, bool doNubMatching) {
if (!matches[i]) { continue; }
auto *identifier = DriverBundleIdentifiers[i];
DBGLOG("NRed", "Injecting personalities for %s.", identifier);
auto *driversObj = getDriverXMLForBundle(identifier);
auto *drivers = OSDynamicCast(OSArray, driversObj);
size_t len;
auto *driverXML = getDriverXMLForBundle(identifier, &len);

OSString *errStr = nullptr;
auto *dataUnserialized = OSUnserializeXML(driverXML, len, &errStr);
delete[] driverXML;

PANIC_COND(!dataUnserialized, "NRed", "Failed to unserialize driver XML for %s: %s", identifier,
errStr ? errStr->getCStringNoCopy() : "(nil)");

auto *drivers = OSDynamicCast(OSArray, dataUnserialized);
PANIC_COND(drivers == nullptr, "NRed", "Failed to cast %s driver data", identifier);
if (!FunctionCast(wrapAddDrivers, callback->orgAddDrivers)(that, drivers, doNubMatching)) {
SYSLOG("NRed", "Error: Failed to inject personalities for %s.", identifier);
}
OSSafeReleaseNULL(drivers);
dataUnserialized->release();
}
return res;
}
Expand Down
2 changes: 1 addition & 1 deletion NootedRed/NRed.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ class NRed {
friend class X6000;
friend class X5000;

public:
static NRed *callback;

public:
void init();
void processPatcher(KernelPatcher &patcher);
void setRMMIOIfNecessary();
Expand Down
3 changes: 2 additions & 1 deletion NootedRed/X5000.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
class X5000 {
friend class X6000;

public:
static X5000 *callback;

public:
void init();
bool processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t slide, size_t size);

Expand Down
3 changes: 2 additions & 1 deletion NootedRed/X6000.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
class X6000 {
friend class X5000;

public:
static X6000 *callback;

public:
void init();
bool processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t slide, size_t size);

Expand Down
3 changes: 2 additions & 1 deletion NootedRed/X6000FB.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ using t_DcLinkSetBacklightLevelNits = bool (*)(void *link, bool isHDR, UInt32 ba
class X6000FB {
friend class NRed;

public:
static X6000FB *callback;

public:
void init();
bool processKext(KernelPatcher &patcher, size_t id, mach_vm_address_t slide, size_t size);

Expand Down

0 comments on commit b74ac1c

Please sign in to comment.