Skip to contentSkip to conversation

remove '\n' in fscanf format-string

PATCH In review Yuanchao Sun 2 participants 4 messages Nov 28, 2017

lore
Share & tools
lore
#0 lore raw

cover remove '\n' in fscanf format-string

Hi,

fscanf will not return until a non-whitespace
character is read after errno=0\n\n

Yuanchao Sun (1):
tools: remove '\n' in fscanf format-string

 src/tools/ipc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Signature · 1 line
2.15.0
#1 lore raw

PATCH 1/1 tools: remove '\n' in fscanf format-string

---
 src/tools/ipc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/tools/ipc.c +1 -1
index a88672f..7264848 100644
@@ -271,7 +271,7 @@ static int userspace_set_device(struct wgdevice *dev)
 	fprintf(f, "\n");
 	fflush(f);
 
-	if (fscanf(f, "errno=%d\n\n", &ret) != 1)
+	if (fscanf(f, "errno=%d", &ret) != 1)
 		ret = errno ? -errno : -EPROTO;
 	fclose(f);
 	errno = -ret;
Signature · 1 line
2.15.0
#2 lore raw

Re: [PATCH 1/1] tools: remove '\n' in fscanf format-string

Hello,

Thanks for the patch. In the future, please include your Signed-off-by line and include the explanation in the body of the commit where it will be recorded in the future.

I'm not sure this patch is correct. The /xplatform spec mandates an empty line. This patch enforces that. What is the purpose of removing that requirement?

Also, I'm curious to learn what you're doing with this API at this early stage.

Regards,
Jason

#3 lore raw

Re: [PATCH 1/1] tools: remove '\n' in fscanf format-string

Hi Jason,

Quoted 3 lines

Thanks for the patch. In the future, please include your Signed-off-by line and include the explanation in the body of the commit where it will be recorded in the future.

Sure. This is my first time using git send-email ... I just followed the = steps
from a quick guide. I will figure out how to add the Signed-off-by line the next time.

Quoted 6 lines

=20
I'm not sure this patch is correct. The /xplatform spec mandates an empty line. This patch enforces that. What is the purpose of removing that requirement?
=20
Also, I'm curious to learn what you're doing with this API at this =

early stage.

I'm trying to implement a userspace client using rust (does not work = properly
for now ;/ ).

But I found fscanf does not return after reading a complete response = (b"errno=3D0\n\n").
After searching, it seems '\n' in format string does not mean newline = but any whitespaces.
fscanf hangs until a extra non-whitespace character.
So I fix this problem by removing the trailing '\n's in format string.

Yuanchao