staging: keucr: Use strncmp() instead of custom StringCmp() and some style cleanups
Subsystems (2)
PATCH 1/4 staging: keucr: Use strncmp() instead of custom StringCmp() and some style cleanups
--- drivers/staging/keucr/smilsub.c | 66 ++++++++++++++++++++------------------- 1 files changed, 34 insertions(+), 32 deletions(-)
drivers/staging/keucr/smilsub.c +34 -32
@@ -1482,54 +1482,56 @@ BYTE _Check_D_DevCode(BYTE dcode)//----- Check_D_ReadError() ---------------------------------------------- int Check_D_ReadError (BYTE *redundant) { -// Driver 不做 ECC Check -return (SUCCESS ); -if (!StringCmp ((char *)(redundant+0x0D ),(char *)EccBuf,3 )) -if (!StringCmp ((char *)(redundant+0x08 ),(char *)(EccBuf+0x03 ),3 )) -return (SUCCESS ); - -return (ERROR ); +/* Driver ECC Check */ +return SUCCESS ; +if (!strncmp ((char *)(redundant+0x0D ), (char *)EccBuf,3 )) +if (!strncmp ((char *)(redundant+0x08 ), + (char *)(EccBuf+0x03 ),3 )) +return SUCCESS ; + +return ERROR ; }//----- Check_D_Correct() ---------------------------------------------- int Check_D_Correct (BYTE *buf,BYTE *redundant) { -// Driver 不做 ECC Check -return (SUCCESS ); -if (StringCmp ((char *)(redundant+0x0D ),(char *)EccBuf,3 )) -if (_Correct_D_SwECC (buf,redundant+0x0D ,EccBuf)) -return (ERROR ); - - buf+=0x100 ; -if (StringCmp ((char *)(redundant+0x08 ),(char *)(EccBuf+0x03 ),3 )) -if (_Correct_D_SwECC (buf,redundant+0x08 ,EccBuf+0x03 )) -return (ERROR ); - -return (SUCCESS ); +/* Driver ECC Check */ +return SUCCESS ; +if (strncmp ((char *)(redundant+0x0D ), (char *)EccBuf,3 )) +if (_Correct_D_SwECC (buf, redundant+0x0D , EccBuf)) +return ERROR ; + + buf +=0x100 ; +if (strncmp ((char *)(redundant+0x08 ), (char *)(EccBuf+0x03 ),3 )) +if (_Correct_D_SwECC (buf, redundant+0x08 , EccBuf+0x03 )) +return ERROR ; + +return SUCCESS ; }//----- Check_D_CISdata() ---------------------------------------------- int Check_D_CISdata (BYTE *buf,BYTE *redundant) { -BYTE cis[]={0x01 ,0x03 ,0xD9 ,0x01 ,0xFF ,0x18 ,0x02 ,0xDF ,0x01 ,0x20 }; +BYTE cis[] = {0x01 ,0x03 ,0xD9 ,0x01 ,0xFF ,0x18 ,0x02 , +0xDF ,0x01 ,0x20 }; -if (!IsSSFDCCompliance && !IsXDCompliance) -return (SUCCESS );// 目前為強制 SUCCESS [Arnold 02-08-23] SSFDC 測試, 不能強制 SUCCESS +if (!IsSSFDCCompliance && !IsXDCompliance) +return SUCCESS ; -if (!StringCmp ((char *)(redundant+0x0D ),(char *)EccBuf,3 )) -return (StringCmp ((char *)buf,(char *)cis,10 )); +if (!strncmp ((char *)(redundant+0x0D ), (char *)EccBuf,3 )) +return strncmp ((char *)buf, (char *)cis,10 ); -if (!_Correct_D_SwECC (buf,redundant+0x0D ,EccBuf)) -return (StringCmp ((char *)buf,(char *)cis,10 )); +if (!_Correct_D_SwECC (buf, redundant+0x0D , EccBuf)) +return strncmp ((char *)buf, (char *)cis,10 ); - buf+=0x100 ; -if (!StringCmp ((char *)(redundant+0x08 ),(char *)(EccBuf+0x03 ),3 )) -return (StringCmp ((char *)buf,(char *)cis,10 )); + buf +=0x100 ; +if (!strncmp ((char *)(redundant+0x08 ), (char *)(EccBuf+0x03 ),3 )) +return strncmp ((char *)buf, (char *)cis,10 ); -if (!_Correct_D_SwECC (buf,redundant+0x08 ,EccBuf+0x03 )) -return (StringCmp ((char *)buf,(char *)cis,10 )); +if (!_Correct_D_SwECC (buf, redundant+0x08 , EccBuf+0x03 )) +return strncmp ((char *)buf, (char *)cis,10 ); -return (ERROR ); +return ERROR ; }//----- Set_D_RightECC() ----------------------------------------------
Signature · 6 lines
1.7.0.4 -- To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/4] staging: keucr: Use strncmp() instead of custom
Quoted 6 lines · Javier Martinez Canillas
//-----
Check_D_CISdata()---------------------------------------------- intCheck_D_CISdata(BYTE *buf, BYTE *redundant)
{drivers/staging/keucr/smilsub.c +2
-1-BYTE cis[]={0x01 ,0x03 ,0xD9 ,0x01 ,0xFF ,0x18 ,0x02 ,0xDF ,0x01 ,0x20 }; +BYTE cis[] = {0x01 ,0x03 ,0xD9 ,0x01 ,0xFF ,0x18 ,0x02 , +0xDF ,0x01 ,0x20 };
drivers/staging/keucr/smilsub.c BYTE _Check_D_DevCode(BYTE dcode) · line 1522
Quoted 10 lines
drivers/staging/keucr/smilsub.c +4
-4-if (!IsSSFDCCompliance && !IsXDCompliance) -return (SUCCESS );// 目前為強制 SUCCESS [Arnold 02-08-23] SSFDC 測試, 不能強制 SUCCESS +if (!IsSSFDCCompliance && !IsXDCompliance) +return SUCCESS ; -if (!StringCmp ((char *)(redundant+0x0D ),(char *)EccBuf,3 )) -return (StringCmp ((char *)buf,(char *)cis,10 )); +if (!strncmp ((char *)(redundant+0x0D ), (char *)EccBuf,3 )) +return strncmp ((char *)buf, (char *)cis,10 );
"cis" isn't a string. I suspect none of these are. Use memcmp() instead of strncmp(). With memcmp() you can get rid of the cast. Also use sizeof(cis) instead of hardcoding it to 10.
Eventually we should also put all the 0x0D magic variables in defines as well.
regards,
dan carpenter
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html