Skip to contentSkip to conversation

staging: keucr: Use strncpy() instead of custom StringCopy() and some style cleanups

PATCH In review Javier Martinez Canillas 2 participants 3 messages Dec 31, 2010

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 2/4 staging: keucr: Use strncpy() instead of custom StringCopy() and some style cleanups

---
 drivers/staging/keucr/smilecc.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)
drivers/staging/keucr/smilecc.c +9 -7
index daf322a..f4ff9ac 100644
@@ -182,13 +182,15 @@ BYTE *buf;
 BYTE *redundant_ecc;
 BYTE *calculate_ecc;
 {
-    DWORD err;
-
-    err=correct_data(buf,redundant_ecc,*(calculate_ecc+1),*(calculate_ecc),*(calculate_ecc+2));
-    if (err=1) StringCopy(calculate_ecc,redundant_ecc,3);
-        if (err=0 || err=1 || err=2)
-            return(0);
-    return(-1);
+	DWORD err;
+	err = correct_data(buf, redundant_ecc, *(calculate_ecc+1),
+			   *(calculate_ecc), *(calculate_ecc+2));
+	if (err = 1)
+		strncpy(calculate_ecc, redundant_ecc, 3);
+
+	if (err = 0 || err = 1 || err = 2)
+		return 0;
+	return -1;
 }
 
 void _Calculate_D_SwECC(buf,ecc)
Signature · 1 line
1.7.0.4
#1 lore raw

Re: [PATCH 2/4] staging: keucr: Use strncpy() instead of custom

In the original code the StringCopy() function was equivalent to memcpy(). I don't know if the source string (which is probably not an actual string with this code) had NULL characters but if it did, that could cause bugs.

regards,
dan carpenter

#2 lore raw

Re: [PATCH 2/4] staging: keucr: Use strncpy() instead of custom

In reply to Javier Martinez Canillas
Quoted 9 lines · Dan Carpenter

In the original code the StringCopy() function was equivalent to memcpy().  I don't know if the source string (which is probably not an actual string with this code) had NULL characters but if it did, that could cause bugs.

regards,
dan carpenter

Thank you for the review. I will prepare a new set of patches based in your recommendations and resend.

Signature · 5 lines
Best regards,

-----------------------------------------
Javier Martínez Canillas
(+34) 682 39 81 69