Skip to contentSkip to conversation

Add cast so negate operation works correctly.

PATCH New Steve Ellcey 2 participants 2 messages Feb 28, 2017 – Mar 1, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add cast so negate operation works correctly.

Cast the result of sizeof to (off_t) so that we have a signed value before we negate it. Otherwise we will get the wrong value in cases where sizeof returns a 32 bit unsigned type and off_t is a 64 bit signed type. This shows up on x86_64 when compiling with -mx32.

---
 testcases/kernel/fs/ftest/ftest02.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/fs/ftest/ftest02.c +1 -1
index f205961..a416a98 100644
@@ -268,7 +268,7 @@ static void crfile(int me, int count)
 	val = write(fd, crmsg, sizeof(crmsg) - 1);
 	warn(val, "write", 0);
 
-	val = lseek(fd, -(sizeof(crmsg) - 1), 1);
+	val = lseek(fd, -((off_t) sizeof(crmsg) - 1), 1);
 	warn(val, "lseek", 0);
 
 	val = read(fd, buf, sizeof(crmsg) - 1);
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 Add cast so negate operation works correctly.

Hi!
Here as well, patch is correct, the description needs to be adjusted a bit.

Signature · 2 lines
Cyril Hrubis
[email protected]