staging: keucr: Use memcmp() instead custom StringCmp() and some style cleanups
Subsystems (2)
PATCH 1/3 staging: keucr: Use memcmp() instead custom StringCmp() and some style cleanups
--- drivers/staging/keucr/smilsub.c | 59 ++++++++++++++++++++------------------- 1 files changed, 30 insertions(+), 29 deletions(-)
drivers/staging/keucr/smilsub.c +30 -29
@@ -1482,54 +1482,55 @@ 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 ); +/* Driver ECC Check */ +if (memcmp (redundant +0x0D , EccBuf,3 ) || +memcmp (redundant +0x08 , EccBuf +0x03 ,3 )) +return ERROR ; -return (ERROR ); +return SUCCESS ; }//----- 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 ); +/* Driver ECC Check */ +if (memcmp (redundant +0x0D , EccBuf,3 ) && +_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 ); + buf +=0x100 ; +if (memcmp (redundant +0x08 , EccBuf +0x03 ,3 ) && +_Correct_D_SwECC (buf, redundant +0x08 , EccBuf +0x03 )) +return ERROR ; -return (SUCCESS ); +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 }; + +int cis_len =sizeof (cis); -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 (!memcmp (redundant +0x0D , EccBuf,3 )) +return memcmp (buf, cis, cis_len); -if (!_Correct_D_SwECC (buf,redundant+0x0D ,EccBuf)) -return (StringCmp ((char *)buf,(char *)cis,10 )); +if (!_Correct_D_SwECC (buf, redundant +0x0D , EccBuf)) +return memcmp (buf, cis, cis_len); - buf+=0x100 ; -if (!StringCmp ((char *)(redundant+0x08 ),(char *)(EccBuf+0x03 ),3 )) -return (StringCmp ((char *)buf,(char *)cis,10 )); + buf +=0x100 ; +if (!memcmp (redundant +0x08 , EccBuf +0x03 ,3 )) +return memcmp (buf, cis, cis_len); -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 memcmp (buf, cis, cis_len); -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/3] staging: keucr: Use memcmp() instead custom
Quoted 9 lines · Javier Martinez Canillas
Signed-off-by Javier Martinez Canillas <[email protected]>drivers/staging/keucr/smilsub.c +0
-3@@ -1482,54 +1482,55 @@ 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 ))
drivers/staging/keucr/smilsub.c BYTE _Check_D_DevCode(BYTE dcode) · line 1491
Quoted 10 lines
drivers/staging/keucr/smilsub.c +5
-3-if (!StringCmp ((char *)(redundant+0x08 ),(char *)(EccBuf+0x03 ),3 )) -return (SUCCESS ); +/* Driver ECC Check */ +if (memcmp (redundant +0x0D , EccBuf,3 ) || +memcmp (redundant +0x08 , EccBuf +0x03 ,3 )) +return ERROR ; -return (ERROR ); +return SUCCESS ; }
This code isn't the same.
Before, the return was always SUCCESS and the code after the first return was ignored.
You deleted that return and now you do the driver ECC check. Is that correct?
drivers/staging/keucr/smilsub.c BYTE _Check_D_DevCode(BYTE dcode)
Quoted 12 lines
drivers/staging/keucr/smilsub.c +4
-5//----- 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 ); +/* Driver ECC Check */ +if (memcmp (redundant +0x0D , EccBuf,3 ) && +_Correct_D_SwECC (buf, redundant +0x0D , EccBuf)) +return ERROR
Here too.
Re: [PATCH 1/3] staging: keucr: Use memcmp() instead custom
In reply to Javier Martinez CanillasQuoted 16 lines
Quoted 12 lines
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);
+ /* Driver ECC Check */
+ if (memcmp(redundant + 0x0D, EccBuf, 3)||
+memcmp(redundant + 0x08, EccBuf + 0x03, 3))
+ return ERROR;Quoted 3 lines
- return(ERROR);
+ return SUCCESS;
}
Quoted 8 lines
This code isn't the same.
Before, the return was always SUCCESS and the code after the first return was ignored.
You deleted that return and now you do the driver ECC check. Is that correct?
You are right Joe, sorry for that. Should I remove the dead code after the return SUCCESS or keep it?
Signature · 5 lines
Best regards, ----------------------------------------- Javier Martínez Canillas (+34) 682 39 81 69
Re: [PATCH 1/3] staging: keucr: Use memcmp() instead custom
In reply to Javier Martinez CanillasQuoted 5 lines · Javier Martinez Canillas
Quoted 3 lines
This code isn't the same.
You deleted that return and now you do the driver ECC check. Is that correct?You are right Joe, sorry for that. Should I remove the dead code after the return SUCCESS or keep it?
As I said before, I think you should delete it.
Quoted 3 lines · Joe Perches
You might as well take out useless code after returns instead of just changing function names.
If you keep it you should reformat it.
Doesn't matter much though.
cheers, Joe