Skip to contentSkip to conversation

test_and_set_bit returns oldval

PATCH Applied Serge E. Hallyn 2 participants 2 messages Oct 18, 2009 – Oct 19, 2009 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test_and_set_bit returns oldval

ckpt_set_ctx_error() was not setting ctx->errno when it should - it apparently thought that test_and_set_bit(x,y) would return 1 if the set_bit succeeded?

Fix ckpt_set_ctx_error() to set ctx->errno the first (and only the first) time that CKPT_CTX_ERROR gets set in ctx->kflags.

---
 include/linux/checkpoint.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/linux/checkpoint.h +1 -1
index 4b61378..c550039 100644
@@ -111,7 +111,7 @@ extern int ckpt_sock_getnames(struct ckpt_ctx *ctx,
 
 static inline void ckpt_set_ctx_error(struct ckpt_ctx *ctx, int errno)
 {
-	if (ckpt_test_and_set_ctx_kflag(ctx, CKPT_CTX_ERROR))
+	if (!ckpt_test_and_set_ctx_kflag(ctx, CKPT_CTX_ERROR))
 		ctx->errno = errno;
 }
 
Signature · 1 line
1.6.1

A message that is not in the archive (sent off-list or not yet received): 20091018211911.GA17271-r/[email protected]

Applied
#2 lore raw
Quoted 6 lines · Serge E. Hallyn

ckpt_set_ctx_error() was not setting ctx->errno when it should - it apparently thought that test_and_set_bit(x,y) would return 1 if the set_bit succeeded?

Fix ckpt_set_ctx_error() to set ctx->errno the first (and only the first) time that CKPT_CTX_ERROR gets set in ctx->kflags.

Yeah .. and it explains why you never saw the error as you expected.

Applied, thanks !

Quoted 19 lines
---
 include/linux/checkpoint.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/linux/checkpoint.h +1 -1
index 4b61378..c550039 100644
@@ -111,7 +111,7 @@ extern int ckpt_sock_getnames(struct ckpt_ctx *ctx,
 
 static inline void ckpt_set_ctx_error(struct ckpt_ctx *ctx, int errno)
 {
-	if (ckpt_test_and_set_ctx_kflag(ctx, CKPT_CTX_ERROR))
+	if (!ckpt_test_and_set_ctx_kflag(ctx, CKPT_CTX_ERROR))
 		ctx->errno = errno;
 }