staging: vt6656: aes_ccmp, baseband, bssdb, card: Change BOOL to int
PATCH 1/2 staging: vt6656: aes_ccmp, baseband, bssdb, card: Change BOOL to int
This patch change all references of BOOL to int. As asked by the TODO file of the driver, we need to remove the ttype.h, and this file do a typedef of int to BOOL. We don't need this.
--- drivers/staging/vt6656/aes_ccmp.c | 4 +- drivers/staging/vt6656/aes_ccmp.h | 2 +- drivers/staging/vt6656/baseband.c | 11 ++++----- drivers/staging/vt6656/baseband.h | 8 ++---- drivers/staging/vt6656/bssdb.c | 16 +++++++------- drivers/staging/vt6656/bssdb.h | 42 ++++++++++++++++++------------------ drivers/staging/vt6656/card.c | 26 +++++++++++----------- drivers/staging/vt6656/card.h | 16 +++++++------- 8 files changed, 61 insertions(+), 64 deletions(-)
drivers/staging/vt6656/aes_ccmp.c +2 -2
@@ -231,7 +231,7 @@ void AESv128(BYTE *key, BYTE *data, BYTE *ciphertext)* */ -BOOL AESbGenCCMP (PBYTE pbyRxKey,PBYTE pbyFrame,WORD wFrameSize) +int AESbGenCCMP (PBYTE pbyRxKey,PBYTE pbyFrame,WORD wFrameSize) {BYTE abyNonce[13 ];BYTE MIC_IV [16 ];
@@ -249,7 +249,7 @@ BOOL AESbGenCCMP(PBYTE pbyRxKey, PBYTE pbyFrame, WORD wFrameSize)WORD wHLen =22 ;/* 8 is IV, 8 is MIC, 4 is CRC */ WORD wPayloadSize = wFrameSize -8 -8 -4 -WLAN_HDR_ADDR3_LEN ; -BOOL bA4 = FALSE; +int bA4 = FALSE;BYTE byTmp;WORD wCnt;int ii, jj, kk;
drivers/staging/vt6656/aes_ccmp.h +1 -1
@@ -41,6 +41,6 @@/*--------------------- Export Variables --------------------------*/ /*--------------------- Export Functions --------------------------*/ -BOOL AESbGenCCMP (PBYTE pbyRxKey,PBYTE pbyFrame,WORD wFrameSize); +int AESbGenCCMP (PBYTE pbyRxKey,PBYTE pbyFrame,WORD wFrameSize);#endif /* __AES_CCMP_H__ */
drivers/staging/vt6656/baseband.c +5 -6
@@ -770,9 +770,9 @@ BBvCaculateParameter (unsigned int cbBitCount;unsigned int cbUsCount =0 ;unsigned int cbTmp; -BOOL bExtBit; +int bExtBit;BYTE byPreambleType = pDevice->byPreambleType; -BOOL bCCK = pDevice->bCCK; +int bCCK = pDevice->bCCK; cbBitCount = cbFrameLength *8 ; bExtBit = FALSE;
@@ -990,7 +990,7 @@ BBvSetAntennaMode (PSDevice pDevice, BYTE byAntennaMode)* */ -BOOL BBbVT3184Init (PSDevice pDevice) +int BBbVT3184Init (PSDevice pDevice) {int ntStatus;WORD wLength;
@@ -1641,9 +1641,8 @@ void TimerSQ3Tmax3CallBack(void *hDeviceContext) }void -BBvUpdatePreEDThreshold ( -PSDevice pDevice, -BOOL bScanning) +BBvUpdatePreEDThreshold (PSDevice pDevice, +int bScanning) {
drivers/staging/vt6656/baseband.h +3 -5
@@ -125,12 +125,10 @@ void BBvSoftwareReset(PSDevice pDevice);void BBvSetShortSlotTime (PSDevice pDevice);void BBvSetVGAGainOffset (PSDevice pDevice,BYTE byData);void BBvSetAntennaMode (PSDevice pDevice,BYTE byAntennaMode); -BOOL BBbVT3184Init (PSDevice pDevice); +int BBbVT3184Init (PSDevice pDevice);void BBvSetDeepSleep (PSDevice pDevice);void BBvExitDeepSleep (PSDevice pDevice); -void BBvUpdatePreEDThreshold ( -PSDevice pDevice, -BOOL bScanning - ); +void BBvUpdatePreEDThreshold (PSDevice pDevice, +int bScanning);#endif /* __BASEBAND_H__ */
drivers/staging/vt6656/bssdb.c +8 -8
@@ -282,7 +282,7 @@ pDevice->bSameBSSMaxNum = jj;-*/ -void BSSvClearBSSList (void *hDeviceContext,BOOL bKeepCurrBSSID) +void BSSvClearBSSList (void *hDeviceContext,int bKeepCurrBSSID) {PSDevice pDevice = (PSDevice )hDeviceContext;PSMgmtObject pMgmt = &(pDevice->sMgmtObj);
@@ -363,7 +363,7 @@ PKnownBSS BSSpAddrIsInBSSList(void *hDeviceContext,* -*/ -BOOL BSSbInsertToBSSList(void *hDeviceContext, +int BSSbInsertToBSSList(void *hDeviceContext, PBYTE abyBSSIDAddr, QWORD qwTimestamp, WORD wBeaconInterval,
@@ -387,7 +387,7 @@ BOOL BSSbInsertToBSSList(void *hDeviceContext,PSRxMgmtPacket pRxPacket = (PSRxMgmtPacket )pRxPacketContext;PKnownBSS pBSSList =NULL ;unsigned int ii; -BOOL bParsingQuiet = FALSE; +int bParsingQuiet = FALSE;
@@ -487,7 +487,7 @@ BOOL BSSbInsertToBSSList(void *hDeviceContext,if ((pMgmt->eAuthenMode ==WMAC_AUTH_WPA2 ) || (pBSSList->bWPA2Valid == TRUE)) {PSKeyItem pTransmitKey =NULL ; -BOOL bIs802_1x = FALSE; +int bIs802_1x = FALSE;for (ii =0 ; ii < pBSSList->wAKMSSAuthCount; ii ++) {if (pBSSList->abyAKMSSAuthType[ii] == WLAN_11i_AKMSS_802_1X) {
@@ -584,12 +584,12 @@ BOOL BSSbInsertToBSSList(void *hDeviceContext,-*/ // TODO: input structure modify -BOOL BSSbUpdateToBSSList(void *hDeviceContext, +int BSSbUpdateToBSSList(void *hDeviceContext, QWORD qwTimestamp, WORD wBeaconInterval, WORD wCapInfo, BYTE byCurrChannel, - BOOL bChannelHit, + int bChannelHit, PWLAN_IE_SSID pSSID, PWLAN_IE_SUPP_RATES pSuppRates, PWLAN_IE_SUPP_RATES pExtSuppRates,
@@ -608,7 +608,7 @@ BOOL BSSbUpdateToBSSList(void *hDeviceContext,PSMgmtObject pMgmt = &(pDevice->sMgmtObj);PSRxMgmtPacket pRxPacket = (PSRxMgmtPacket )pRxPacketContext;signed long ldBm, ldBmSum; -BOOL bParsingQuiet = FALSE; +int bParsingQuiet = FALSE;// BYTE abyTmpSSID[WLAN_IEHDR_LEN + WLAN_SSID_MAXLEN + 1];
@@ -729,7 +729,7 @@ BOOL BSSbUpdateToBSSList(void *hDeviceContext,* -*/ -BOOL BSSbIsSTAInNodeDB (void *hDeviceContext, +int BSSbIsSTAInNodeDB (void *hDeviceContext,PBYTE abyDstAddr,unsigned int *puNodeIndex) {
drivers/staging/vt6656/bssdb.h +21 -21
123 lines not on this page · raw message
drivers/staging/vt6656/card.c +13 -13
@@ -95,10 +95,10 @@ const WORD cwRXBCNTSFOff[MAX_RATE] =* Return Value: TRUE if succeeded; FALSE if failed. * */ -BOOL CARDbSetMediaChannel (void *pDeviceHandler,unsigned int uConnectionChannel) +int CARDbSetMediaChannel (void *pDeviceHandler,unsigned int uConnectionChannel) {PSDevice pDevice = (PSDevice ) pDeviceHandler; -BOOL bResult = TRUE; +int bResult = TRUE;if (pDevice->byBBType ==BB_TYPE_11A ) {// 15 ~ 38
@@ -506,7 +506,7 @@ void vUpdateIFS(void *pDeviceHandler) }else {// PK_TYPE_11GA & PK_TYPE_11GB BYTE byRate =0 ; -BOOL bOFDMRate = FALSE; +int bOFDMRate = FALSE;unsigned int ii =0 ;PWLAN_IE_SUPP_RATES pItemRates =NULL ;
@@ -607,7 +607,7 @@ BYTE ii;* Return Value: TRUE if succeeded; FALSE if failed. * */ -BOOL CARDbAddBasicRate (void *pDeviceHandler,WORD wRateIdx) +int CARDbAddBasicRate (void *pDeviceHandler,WORD wRateIdx) {PSDevice pDevice = (PSDevice ) pDeviceHandler;WORD wRate = (WORD )(1 <<wRateIdx);
@@ -620,7 +620,7 @@ WORD wRate = (WORD)(1<<wRateIdx);return (TRUE); } -BOOL CARDbIsOFDMinBasicRate (void *pDeviceHandler) +int CARDbIsOFDMinBasicRate (void *pDeviceHandler) {PSDevice pDevice = (PSDevice ) pDeviceHandler;int ii;
@@ -754,7 +754,7 @@ void CARDvAdjustTSF(void *pDeviceHandler, BYTE byRxRate,* Return Value: TRUE if success; otherwise FALSE * */ -BOOL CARDbGetCurrentTSF (void *pDeviceHandler,PQWORD pqwCurrTSF) +int CARDbGetCurrentTSF (void *pDeviceHandler,PQWORD pqwCurrTSF) {PSDevice pDevice = (PSDevice ) pDeviceHandler;
@@ -776,7 +776,7 @@ BOOL CARDbGetCurrentTSF(void *pDeviceHandler, PQWORD pqwCurrTSF)* Return Value: TRUE if success; otherwise FALSE * */ -BOOL CARDbClearCurrentTSF (void *pDeviceHandler) +int CARDbClearCurrentTSF (void *pDeviceHandler) {PSDevice pDevice = (PSDevice ) pDeviceHandler;
@@ -944,10 +944,10 @@ void CARDvUpdateNextTBTT(void *pDeviceHandler, QWORD qwTSF,* Return Value: TRUE if success; otherwise FALSE * */ -BOOL CARDbRadioPowerOff (void *pDeviceHandler) +int CARDbRadioPowerOff (void *pDeviceHandler) {PSDevice pDevice = (PSDevice ) pDeviceHandler; -BOOL bResult = TRUE; +int bResult = TRUE;//if (pDevice->bRadioOff == TRUE) // return TRUE;
@@ -985,10 +985,10 @@ BOOL bResult = TRUE;* Return Value: TRUE if success; otherwise FALSE * */ -BOOL CARDbRadioPowerOn (void *pDeviceHandler) +int CARDbRadioPowerOn (void *pDeviceHandler) {PSDevice pDevice = (PSDevice ) pDeviceHandler; -BOOL bResult = TRUE; +int bResult = TRUE;if ((pDevice->bHWRadioOff == TRUE) || (pDevice->bRadioControlOff == TRUE)) {
@@ -1077,7 +1077,7 @@ void CARDvSetBSSMode(void *pDeviceHandler)* Return Value: none. * -*/ -BOOL +int CARDbChannelSwitch ( void *pDeviceHandler, BYTE byMode,
@@ -1086,7 +1086,7 @@ CARDbChannelSwitch ( ) {PSDevice pDevice = (PSDevice ) pDeviceHandler; -BOOL bResult = TRUE; +int bResult = TRUE;if (byCount ==0 ) { pDevice->sMgmtObj.uCurrChannel = byNewChannel;
drivers/staging/vt6656/card.h +8 -8
@@ -60,28 +60,28 @@ typedef enum _CARD_OP_MODE {/*--------------------- Export Functions --------------------------*/ -BOOL CARDbSetMediaChannel (void *pDeviceHandler, +int CARDbSetMediaChannel (void *pDeviceHandler,unsigned int uConnectionChannel);void CARDvSetRSPINF (void *pDeviceHandler,BYTE byBBType);void vUpdateIFS (void *pDeviceHandler);void CARDvUpdateBasicTopRate (void *pDeviceHandler); -BOOL CARDbAddBasicRate (void *pDeviceHandler,WORD wRateIdx); -BOOL CARDbIsOFDMinBasicRate (void *pDeviceHandler); +int CARDbAddBasicRate (void *pDeviceHandler,WORD wRateIdx); +int CARDbIsOFDMinBasicRate (void *pDeviceHandler);void CARDvAdjustTSF (void *pDeviceHandler,BYTE byRxRate,QWORD qwBSSTimestamp,QWORD qwLocalTSF); -BOOL CARDbGetCurrentTSF (void *pDeviceHandler,PQWORD pqwCurrTSF); -BOOL CARDbClearCurrentTSF (void *pDeviceHandler); +int CARDbGetCurrentTSF (void *pDeviceHandler,PQWORD pqwCurrTSF); +int CARDbClearCurrentTSF (void *pDeviceHandler);void CARDvSetFirstNextTBTT (void *pDeviceHandler,WORD wBeaconInterval);void CARDvUpdateNextTBTT (void *pDeviceHandler,QWORD qwTSF,WORD wBeaconInterval);QWORD CARDqGetNextTBTT (QWORD qwTSF,WORD wBeaconInterval);QWORD CARDqGetTSFOffset (BYTE byRxRate,QWORD qwTSF1,QWORD qwTSF2); -BOOL CARDbRadioPowerOff (void *pDeviceHandler); -BOOL CARDbRadioPowerOn (void *pDeviceHandler); +int CARDbRadioPowerOff (void *pDeviceHandler); +int CARDbRadioPowerOn (void *pDeviceHandler);BYTE CARDbyGetPktType (void *pDeviceHandler);void CARDvSetBSSMode (void *pDeviceHandler); -BOOL CARDbChannelSwitch (void *pDeviceHandler, +int CARDbChannelSwitch (void *pDeviceHandler,BYTE byMode,BYTE byNewChannel,BYTE byCount);
Signature · 1 line
1.7.4.4
Quoted 4 lines · Marcos Paulo de Souza
This patch change all references of BOOL to int. As asked by the TODO file of the driver, we need to remove the
ttype.h, and this file do a typedef of int to BOOL. We don't need this.
Why not use bool? Especially inside structs bool takes up less space than an int. Also static analysis tools care about the type.
Changing the type from int to bool is a code change so it needs careful auditing. It's not a problem if you don't have this hardware, but you've been sending quite a few patches for it, so I'm curious if you do? If you did, and you made a code change then it helps us to know if you have tested it.
regards,
dan carpenter
Quoted 4 lines · Dan Carpenter
Quoted 3 lines · Marcos Paulo de Souza
This patch change all references of BOOL to int. As asked by the TODO file of the driver, we need to remove the
ttype.h, and this file do a typedef of int to BOOL. We don't need this.
Dan, I'm trying to remove this chunk of code:
drivers/staging/vt6656/ttype.h:
typedef int BOOL;
Are we talinkg about the same BOOL type?
Quoted 3 lines
Why not use bool? Especially inside structs bool takes up less space than an int. Also static analysis tools care about the type.
This typedef is about a int type.
Quoted 5 lines
Changing the type from int to bool is a code change so it needs careful auditing. It's not a problem if you don't have this hardware, but you've been sending quite a few patches for it, so I'm curious if you do? If you did, and you made a code change then it helps us to know if you have tested it.
I made just compile test, and my doubt if this BOOL typedef is same as you are talinkg about.
If this BOOL don't "break" any architeture, I will be happy to remove all of it from vt6656 and vt6655, both with the same horrible ttype.h file.
Thanks for the comments.
Regards,
Marcos Paulo de Souza
Quoted 4 lines
regards,
dan carpenter
Quoted 6 lines · Marcos Paulo de Souza
Quoted 4 lines · Dan Carpenter
Quoted 3 lines · Marcos Paulo de Souza
This patch change all references of BOOL to int. As asked by the TODO file of the driver, we need to remove the
ttype.h, and this file do a typedef of int to BOOL. We don't need this.
Quoted 8 lines
Dan, I'm trying to remove this chunk of code:
drivers/staging/vt6656/ttype.h:typedef int BOOL;
Are we talinkg about the same BOOL type?
Yes.
Quoted 5 lines
Quoted 3 lines
Why not use bool? Especially inside structs bool takes up less space than an int. Also static analysis tools care about the type.
This typedef is about a int type.
Yes. I know that. But these things are used like bool not like int so bool is the correct thing.
Bool is a different type from int, so you'll have to verify that changing it doesn't break anything. It's a more difficult change but it's the right thing to do.
regards,
dan carpenter
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 10 lines · Marcos Paulo de Souza
So, I agree with you. So, we can make some chnages and ask for people to test it? I don't have other hardware than my x86.
So, I think we can remove the typedefs of unsigned char to BYTE.
When I submit some patches chaging this, you ask me to change this to u8.
So, you think I can change this typedefs to theirs respective u8 for unsigned char, u16 for unsigned short and u32 for unsgined long?
What I'm saying is that so often people see the TODO or the output from checkpatch and think, "This is easy, I can just use sed and replace the old code." Sometimes that's the right thing to do, but sometime the original code is not right, like here where it should be using bool but it's using int. So go slowly.
Quoted 3 lines
If it ca generate some crash in other architetures, how we can change it and be sure that nothing bad could happen?
Check if the data is part of the userspace or hardware API or we care about the exact size of the struct for some reason. If it is then we have to leave it as int. Otherwise it should be bool or a bitfield.
regards,
dan carpenter