Development discussion of WireGuard
 help / color / mirror / Atom feed
* [PATCH 0/1] remove '\n' in fscanf format-string
@ 2017-11-28  7:49 Yuanchao Sun
  2017-11-28  7:49 ` [PATCH 1/1] tools: " Yuanchao Sun
  0 siblings, 1 reply; 4+ messages in thread
From: Yuanchao Sun @ 2017-11-28  7:49 UTC (permalink / raw)
  To: wireguard

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(-)

-- 
2.15.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/1] tools: remove '\n' in fscanf format-string
  2017-11-28  7:49 [PATCH 0/1] remove '\n' in fscanf format-string Yuanchao Sun
@ 2017-11-28  7:49 ` Yuanchao Sun
  2017-11-28 11:03   ` Jason A. Donenfeld
  0 siblings, 1 reply; 4+ messages in thread
From: Yuanchao Sun @ 2017-11-28  7:49 UTC (permalink / raw)
  To: wireguard

---
 src/tools/ipc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/tools/ipc.c b/src/tools/ipc.c
index a88672f..7264848 100644
--- a/src/tools/ipc.c
+++ b/src/tools/ipc.c
@@ -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;
-- 
2.15.0

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] tools: remove '\n' in fscanf format-string
  2017-11-28  7:49 ` [PATCH 1/1] tools: " Yuanchao Sun
@ 2017-11-28 11:03   ` Jason A. Donenfeld
  2017-11-28 14:53     ` Yuanchao Sun
  0 siblings, 1 reply; 4+ messages in thread
From: Jason A. Donenfeld @ 2017-11-28 11:03 UTC (permalink / raw)
  To: Yuanchao Sun; +Cc: WireGuard mailing list

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] tools: remove '\n' in fscanf format-string
  2017-11-28 11:03   ` Jason A. Donenfeld
@ 2017-11-28 14:53     ` Yuanchao Sun
  0 siblings, 0 replies; 4+ messages in thread
From: Yuanchao Sun @ 2017-11-28 14:53 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: Yuanchao Sun, WireGuard mailing list

Hi Jason,

> 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.

>=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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-11-28 14:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-28  7:49 [PATCH 0/1] remove '\n' in fscanf format-string Yuanchao Sun
2017-11-28  7:49 ` [PATCH 1/1] tools: " Yuanchao Sun
2017-11-28 11:03   ` Jason A. Donenfeld
2017-11-28 14:53     ` Yuanchao Sun

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).