Skip to content
This repository has been archived by the owner on Nov 21, 2020. It is now read-only.

Commit

Permalink
general: fix all sev-5 cpplint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ellie-idb committed Apr 5, 2020
1 parent 02f1472 commit d124861
Show file tree
Hide file tree
Showing 63 changed files with 511 additions and 1,887 deletions.
9 changes: 4 additions & 5 deletions AppleIntelWifiAdapter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
026C2F702359CB3300C832EF /* IOSkywalkEthernetInterface.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = IOSkywalkEthernetInterface.h; sourceTree = "<group>"; };
026E8CC92356F0ED000BFD46 /* AppleIntelWifiAdapterV2.kext */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AppleIntelWifiAdapterV2.kext; sourceTree = BUILT_PRODUCTS_DIR; };
026E8CCC2356F0ED000BFD46 /* AppleIntelWifiAdapterV2.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AppleIntelWifiAdapterV2.hpp; sourceTree = "<group>"; };
026E8CCE2356F0ED000BFD46 /* AppleIntelWifiAdapterV2.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = AppleIntelWifiAdapterV2.cpp; sourceTree = "<group>"; };
026E8CCE2356F0ED000BFD46 /* AppleIntelWifiAdapterV2.cpp */ = {isa = PBXFileReference; indentWidth = 8; lastKnownFileType = sourcecode.cpp.cpp; path = AppleIntelWifiAdapterV2.cpp; sourceTree = "<group>"; tabWidth = 8; usesTabs = 1; };
026E8CD02356F0ED000BFD46 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
026E8CD72356F2AD000BFD46 /* apple80211_ioctl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = apple80211_ioctl.h; sourceTree = "<group>"; };
026E8CD82356F2AD000BFD46 /* apple80211_wps.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = apple80211_wps.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -394,8 +394,6 @@
68651D6F23F5EE6900A39FAD /* iwlwifi-8265-34.ucode */ = {isa = PBXFileReference; lastKnownFileType = file; path = "iwlwifi-8265-34.ucode"; sourceTree = "<group>"; };
6865B3B52421D65B0044C9FE /* IWLApple80211.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = IWLApple80211.cpp; sourceTree = "<group>"; };
6865B3B62421D65B0044C9FE /* IWLApple80211.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = IWLApple80211.hpp; sourceTree = "<group>"; };
6868731923FA49ED001C7DEA /* HackIONetworkInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HackIONetworkInterface.h; path = AppleIntelWifiAdapter/HackIONetworkInterface.h; sourceTree = SOURCE_ROOT; };
6868731A23FA49ED001C7DEA /* HackIOEthernetInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = HackIOEthernetInterface.h; path = AppleIntelWifiAdapter/HackIOEthernetInterface.h; sourceTree = SOURCE_ROOT; };
6868731D23FA4AB4001C7DEA /* IWLSCD.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; path = IWLSCD.h; sourceTree = "<group>"; };
686AD3E8241C24A6008080E6 /* ioctl_dbg.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ioctl_dbg.h; sourceTree = "<group>"; };
686EA48324377F3A00C88E9B /* OVERVIEW.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = OVERVIEW.md; sourceTree = "<group>"; };
Expand Down Expand Up @@ -500,7 +498,10 @@
026CE67F2357F7F70034342E /* Frameworks */,
68FC255123F5C040004958FC /* Recovered References */,
);
indentWidth = 8;
sourceTree = "<group>";
tabWidth = 8;
usesTabs = 1;
};
026E8CCA2356F0ED000BFD46 /* Products */ = {
isa = PBXGroup;
Expand Down Expand Up @@ -551,8 +552,6 @@
026E8CD72356F2AD000BFD46 /* apple80211_ioctl.h */,
026E8CDA2356F2AD000BFD46 /* apple80211_var.h */,
026E8CD82356F2AD000BFD46 /* apple80211_wps.h */,
6868731A23FA49ED001C7DEA /* HackIOEthernetInterface.h */,
6868731923FA49ED001C7DEA /* HackIONetworkInterface.h */,
0248A083235833CB00A85BA3 /* IO80211Controller.h */,
026E8CDB2356F2AD000BFD46 /* IO80211Interface.h */,
026C2F6F2359CA9600C832EF /* IO80211SkywalkInterface.h */,
Expand Down
94 changes: 46 additions & 48 deletions AppleIntelWifiAdapter/AppleIntelWifiAdapterV2.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
/* add your code here */
//
// AppleIntelWifiAdapterV2.cpp
// AppleIntelWifiAdapter
//
// Created by Harrison Ford on 4/4/20.
// Copyright © 2020 IntelWifi for MacOS authors. All rights reserved.
//

#include "AppleIntelWifiAdapterV2.hpp"

#include <IOKit/IOInterruptController.h>
Expand All @@ -13,28 +20,29 @@ OSDefineMetaClassAndStructors(AppleIntelWifiAdapterV2, IO80211Controller)

#define MBit 1000000

void AppleIntelWifiAdapterV2::releaseAll() {
void AppleIntelWifiAdapterV2::releaseAll()
{
IWL_DEBUG(0, "Releasing everything\n");
if(fInterrupt) {
if (fInterrupt) {
irqLoop->removeEventSource(fInterrupt);
fInterrupt->disable();
fInterrupt = NULL;
}

if(gate) {
if (gate) {
gate->release();
gate = NULL;
}
if(irqLoop) {
if (irqLoop) {
irqLoop->release();
irqLoop = NULL;
}

if(workLoop) {
if (workLoop) {
workLoop->release();
workLoop = NULL;
}
if(netif) {
if (netif) {
netif->release();
netif = NULL;
}
Expand All @@ -45,32 +53,32 @@ void AppleIntelWifiAdapterV2::releaseAll() {
}
}

void AppleIntelWifiAdapterV2::free() {
void AppleIntelWifiAdapterV2::free()
{
IWL_DEBUG(0, "Driver free()\n");
releaseAll();
super::free();
}

bool AppleIntelWifiAdapterV2::init(OSDictionary *properties)
{
IWL_DEBUG(0, "Driver init()\n");
if(!super::init(properties)) {
return false;
}

return true;
IWL_DEBUG(0, "Driver init()\n");
if (!super::init(properties))
return false;

return true;
}

IO80211Interface* AppleIntelWifiAdapterV2::getInterface() {
return netif;
IO80211Interface* AppleIntelWifiAdapterV2::getInterface()
{
return netif;
}

IOService* AppleIntelWifiAdapterV2::probe(IOService *provider, SInt32 *score)
{
IWL_DEBUG(0, "Driver Probe()\n");
if(!super::probe(provider, score)) {
if (!super::probe(provider, score))
return NULL;
}

IOPCIDevice *pciDevice = OSDynamicCast(IOPCIDevice, provider);
if (!pciDevice) {
Expand All @@ -92,13 +100,11 @@ IOService* AppleIntelWifiAdapterV2::probe(IOService *provider, SInt32 *score)
}
}

if(!valid) {
if (!valid)
return NULL;
}

IWL_DEBUG(0, "found pci device====>vendorID=0x%04x, deviceID=0x%04x, subSystemVendorID=0x%04x, subSystemDeviceID=0x%04x, revision=0x%02x\n", vendorID, deviceID, subSystemVendorID, subSystemDeviceID, revision);

//pciDevice->retain();
this->drv = new IWLMvmDriver();
this->drv->m_pDevice = new IWLDevice();
this->drv->m_pDevice->pciDevice = pciDevice;
Expand All @@ -109,9 +115,8 @@ IOService* AppleIntelWifiAdapterV2::probe(IOService *provider, SInt32 *score)
}

bool AppleIntelWifiAdapterV2::createWorkLoop() {
if(!workLoop) {
if (!workLoop)
workLoop = IO80211WorkLoop::workLoop();
}

return (workLoop != NULL);
}
Expand All @@ -123,44 +128,41 @@ IOWorkLoop* AppleIntelWifiAdapterV2::getWorkLoop() const {
bool AppleIntelWifiAdapterV2::start(IOService *provider)
{
IWL_DEBUG(0, "Driver Start()\n");
if (!super::start(provider)) {
if (!super::start(provider))
return false;
}

if(!this->drv) {
if (!this->drv) {
IWL_CRIT(0, "Missing this->drv\n");
releaseAll();
return false;
}

this->drv->controller = static_cast<IO80211Controller*>(this);

if (!this->drv->init()) {
if (!this->drv->init())
return false;
}

if(!this->drv->probe()) {
if (!this->drv->probe())
return false;
}

irqLoop = IO80211WorkLoop::workLoop();

initTimeout(irqLoop);

if(!this->drv->m_pDevice) {
if (!this->drv->m_pDevice) {
IWL_CRIT(0, "Missing this->m_pDevice\n");
releaseAll();
return false;
}

if(!this->drv->m_pDevice->pciDevice) {
if (!this->drv->m_pDevice->pciDevice) {
IWL_CRIT(0, "Missing this->m_pDevice->pciDevice\n");
releaseAll();
return false;
}

gate = IOCommandGate::commandGate(this);
if(!gate) {
if (!gate) {
IWL_CRIT(0, "Failed to create command gate\n");
releaseAll();
return false;
Expand All @@ -179,12 +181,11 @@ IOReturn AppleIntelWifiAdapterV2::_doCommand(OSObject *target, void *arg0, void
int* status = (int*)arg1;
IOService* provider = (IOService*)arg2;

if(arg0 == (void*)16) {
if(!device->startGated(provider)) {
if (arg0 == (void*)16) {
if (!device->startGated(provider)) {
OSIncrementAtomic(status);
}
}
else {
} else {
return kIOReturnError;
}
return kIOReturnSuccess;
Expand Down Expand Up @@ -255,7 +256,7 @@ bool AppleIntelWifiAdapterV2::startGated(IOService *provider) {
return false;
}

if (!setSelectedMedium(mediumTable[MEDIUM_TYPE_AUTO])){
if (!setSelectedMedium(mediumTable[MEDIUM_TYPE_AUTO])) {
IWL_CRIT(0, "start fail, can not set current medium\n");
releaseAll();
return false;
Expand All @@ -268,7 +269,7 @@ bool AppleIntelWifiAdapterV2::startGated(IOService *provider) {
return false;
}

if(!drv->drvStart()) {
if (!drv->drvStart()) {
IWL_CRIT(0, "Driver failed to start\n");
releaseAll();
return false;
Expand All @@ -294,9 +295,8 @@ bool AppleIntelWifiAdapterV2::intrFilter(OSObject *object, IOFilterInterruptEven
{
AppleIntelWifiAdapterV2* me = (AppleIntelWifiAdapterV2*)object;

if(me == 0) {
if (me == 0)
return false;
}

//kprintf("interrupt filter ran\n");
me->drv->trans->iwlWrite32(CSR_INT_MASK, 0x00000000);
Expand All @@ -306,9 +306,8 @@ bool AppleIntelWifiAdapterV2::intrFilter(OSObject *object, IOFilterInterruptEven
void AppleIntelWifiAdapterV2::intrOccured(OSObject *object, IOInterruptEventSource* sender, int count)
{
AppleIntelWifiAdapterV2* o = (AppleIntelWifiAdapterV2*)object;
if(o == 0) {
if (o == 0)
return;
}

kprintf("interrupt!!!\n");
o->drv->irqHandler(0, NULL);
Expand Down Expand Up @@ -343,16 +342,16 @@ void AppleIntelWifiAdapterV2::stop(IOService *provider)
IOReturn AppleIntelWifiAdapterV2::enable(IONetworkInterface *netif)
{
IWL_DEBUG(0, "Driver Enable()\n");
if(super::enable(netif) != kIOReturnSuccess) {
if (super::enable(netif) != kIOReturnSuccess) {
IWL_CRIT(0, "super::enable() failed\n");
return kIOReturnError;
}

IOMediumType mediumType = kIOMediumIEEE80211Auto;
IONetworkMedium *medium = IONetworkMedium::getMediumWithType(mediumDict, mediumType);
setLinkStatus(kIONetworkLinkValid, medium);
if(this->drv) {
if(!this->drv->enableDevice()) {
if (this->drv) {
if (!this->drv->enableDevice()) {
IWL_CRIT(0, "Enabling device failed\n");
return kIOReturnError;
}
Expand All @@ -365,9 +364,8 @@ IOReturn AppleIntelWifiAdapterV2::enable(IONetworkInterface *netif)
}

const OSString* AppleIntelWifiAdapterV2::newModelString() const {
if(drv) {
if (drv)
return OSString::withCString("Wireless Network Adapter (802.11 a/b/g/n/ac)");
}

return OSString::withCString("Wireless Card");
}
Expand Down
15 changes: 11 additions & 4 deletions AppleIntelWifiAdapter/AppleIntelWifiAdapterV2.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
/* add your code here */
#ifndef AppleIntelWifiAdapter_hpp
#define AppleIntelWifiAdapter_hpp
//
// AppleIntelWifiAdapterV2.hpp
// AppleIntelWifiAdapter
//
// Created by Harrison Ford on 4/4/20.
// Copyright © 2020 IntelWifi for MacOS authors. All rights reserved.
//

#ifndef APPLEINTELWIFIADAPTER_APPLEINTELWIFIADAPTERV2_HPP_
#define APPLEINTELWIFIADAPTER_APPLEINTELWIFIADAPTERV2_HPP_

//#include "HackIO80211Interface.h"
#include "IO80211Controller.h"
Expand Down Expand Up @@ -165,4 +172,4 @@ class AppleIntelWifiAdapterV2 : public IO80211Controller

};

#endif
#endif // APPLEINTELWIFIADAPTER_APPLEINTELWIFIADAPTERV2_HPP_
Loading

0 comments on commit d124861

Please sign in to comment.