qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [patch] use socklen_t with getsockopt()
@ 2007-03-31  8:24 Mike Frysinger
  2007-04-01 18:43 ` Thiemo Seufer
  0 siblings, 1 reply; 9+ messages in thread
From: Mike Frysinger @ 2007-03-31  8:24 UTC (permalink / raw)
  To: Qemu-devel


[-- Attachment #1.1: Type: text/plain, Size: 67 bytes --]

obvious fixup ... getsockopt() takes a socklen_t, not an int
-mike

[-- Attachment #1.2: Type: application/pgp-signature, Size: 827 bytes --]

[-- Attachment #2: qemu-socklen-t.patch --]
[-- Type: text/x-diff, Size: 1034 bytes --]

--- linux-user/syscall.c
+++ linux-user/syscall.c
@@ -642,7 +642,8 @@ static long do_setsockopt(int sockfd, in
 static long do_getsockopt(int sockfd, int level, int optname, 
                           target_ulong optval, target_ulong optlen)
 {
-    int len, lv, val, ret;
+    int len, val, ret;
+    socklen_t lv;
 
     switch(level) {
     case TARGET_SOL_SOCKET:
@@ -665,7 +666,7 @@ static long do_getsockopt(int sockfd, in
         len = tget32(optlen);
         if (len < 0)
             return -EINVAL;
-        lv = sizeof(int);
+        lv = sizeof(lv);
         ret = get_errno(getsockopt(sockfd, level, optname, &val, &lv));
         if (ret < 0)
             return ret;
@@ -698,7 +699,7 @@ static long do_getsockopt(int sockfd, in
             len = tget32(optlen);
             if (len < 0)
                 return -EINVAL;
-            lv = sizeof(int);
+            lv = sizeof(lv);
             ret = get_errno(getsockopt(sockfd, level, optname, &val, &lv));
             if (ret < 0)
                 return ret;

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

* Re: [Qemu-devel] [patch] use socklen_t with getsockopt()
  2007-03-31  8:24 Mike Frysinger
@ 2007-04-01 18:43 ` Thiemo Seufer
  2007-04-01 22:25   ` Mike Frysinger
  0 siblings, 1 reply; 9+ messages in thread
From: Thiemo Seufer @ 2007-04-01 18:43 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: Qemu-devel

Mike Frysinger wrote:
> obvious fixup ... getsockopt() takes a socklen_t, not an int
> -mike

This is incorrect. Its initial value is sizeof(val).


Thiemo

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

* Re: [Qemu-devel] [patch] use socklen_t with getsockopt()
  2007-04-01 18:43 ` Thiemo Seufer
@ 2007-04-01 22:25   ` Mike Frysinger
  0 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2007-04-01 22:25 UTC (permalink / raw)
  To: Thiemo Seufer; +Cc: Qemu-devel


[-- Attachment #1.1: Type: text/plain, Size: 208 bytes --]

On Sunday 01 April 2007, Thiemo Seufer wrote:
> Mike Frysinger wrote:
> > obvious fixup ... getsockopt() takes a socklen_t, not an int
>
> This is incorrect. Its initial value is sizeof(val).

attached
-mike

[-- Attachment #1.2: Type: application/pgp-signature, Size: 827 bytes --]

[-- Attachment #2: qemu-socklen-t.patch --]
[-- Type: text/x-diff, Size: 1036 bytes --]

--- linux-user/syscall.c
+++ linux-user/syscall.c
@@ -642,7 +642,8 @@ static long do_setsockopt(int sockfd, in
 static long do_getsockopt(int sockfd, int level, int optname, 
                           target_ulong optval, target_ulong optlen)
 {
-    int len, lv, val, ret;
+    int len, val, ret;
+    socklen_t lv;
 
     switch(level) {
     case TARGET_SOL_SOCKET:
@@ -665,7 +666,7 @@ static long do_getsockopt(int sockfd, in
         len = tget32(optlen);
         if (len < 0)
             return -EINVAL;
-        lv = sizeof(int);
+        lv = sizeof(val);
         ret = get_errno(getsockopt(sockfd, level, optname, &val, &lv));
         if (ret < 0)
             return ret;
@@ -698,7 +699,7 @@ static long do_getsockopt(int sockfd, in
             len = tget32(optlen);
             if (len < 0)
                 return -EINVAL;
-            lv = sizeof(int);
+            lv = sizeof(val);
             ret = get_errno(getsockopt(sockfd, level, optname, &val, &lv));
             if (ret < 0)
                 return ret;

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

* Re : [Qemu-devel] [patch] use socklen_t with getsockopt()
@ 2007-04-05  8:43 Sylvain Petreolle
  2007-04-05 10:42 ` Jamie Lokier
  0 siblings, 1 reply; 9+ messages in thread
From: Sylvain Petreolle @ 2007-04-05  8:43 UTC (permalink / raw)
  To: qemu-devel

Was incorrect before too, since it was sizeof(int) in the first place ?

Sylvain
 
----- Message d'origine ----
De : Thiemo Seufer <ths@networkno.de>
À : Mike Frysinger <vapier@gentoo.org>
Cc : Qemu-devel@nongnu.org
Envoyé le : Dimanche, 1 Avril 2007, 20h43mn 02s
Objet : Re: [Qemu-devel] [patch] use socklen_t with getsockopt()


Mike Frysinger wrote:
> obvious fixup ... getsockopt() takes a socklen_t, not an int
> -mike

This is incorrect. Its initial value is sizeof(val).


Thiemo

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

* Re: Re : [Qemu-devel] [patch] use socklen_t with getsockopt()
  2007-04-05  8:43 Re : [Qemu-devel] [patch] use socklen_t with getsockopt() Sylvain Petreolle
@ 2007-04-05 10:42 ` Jamie Lokier
  2007-04-06 21:51   ` Mike Frysinger
  0 siblings, 1 reply; 9+ messages in thread
From: Jamie Lokier @ 2007-04-05 10:42 UTC (permalink / raw)
  To: Sylvain Petreolle, qemu-devel

Sylvain Petreolle wrote:
> Was incorrect before too, since it was sizeof(int) in the first place ?

The old type of "val" was "int", so it made no different to the size.
When "val" is of type socklen_t, it matters.

-- Jamie

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

* Re: [Qemu-devel] [patch] use socklen_t with getsockopt()
  2007-04-05 10:42 ` Jamie Lokier
@ 2007-04-06 21:51   ` Mike Frysinger
  2007-04-06 21:59     ` Paul Brook
  2007-04-10 10:59     ` Jamie Lokier
  0 siblings, 2 replies; 9+ messages in thread
From: Mike Frysinger @ 2007-04-06 21:51 UTC (permalink / raw)
  To: qemu-devel; +Cc: Sylvain Petreolle

[-- Attachment #1: Type: text/plain, Size: 396 bytes --]

On Thursday 05 April 2007, Jamie Lokier wrote:
> Sylvain Petreolle wrote:
> > Was incorrect before too, since it was sizeof(int) in the first place ?
>
> The old type of "val" was "int", so it made no different to the size.
> When "val" is of type socklen_t, it matters.

val is still of type int which is fine ... socklen_t is for the variable which 
describes the length of val
-mike

[-- Attachment #2: Type: application/pgp-signature, Size: 827 bytes --]

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

* Re: [Qemu-devel] [patch] use socklen_t with getsockopt()
  2007-04-06 21:51   ` Mike Frysinger
@ 2007-04-06 21:59     ` Paul Brook
  2007-04-10 10:59     ` Jamie Lokier
  1 sibling, 0 replies; 9+ messages in thread
From: Paul Brook @ 2007-04-06 21:59 UTC (permalink / raw)
  To: qemu-devel; +Cc: Sylvain Petreolle, Mike Frysinger

On Friday 06 April 2007 22:51, Mike Frysinger wrote:
> On Thursday 05 April 2007, Jamie Lokier wrote:
> > Sylvain Petreolle wrote:
> > > Was incorrect before too, since it was sizeof(int) in the first place ?
> >
> > The old type of "val" was "int", so it made no different to the size.
> > When "val" is of type socklen_t, it matters.
>
> val is still of type int which is fine ... socklen_t is for the variable
> which describes the length of val

It's worth noting that socklen_t should be "int" anyway.
From the accept(2) manpage:

NOTE
       The  third  argument  of accept() was originally declared as an `int *'
       (and is that under libc4 and libc5 and on many other systems  like  4.x
       BSD,  SunOS 4, SGI); a POSIX.1g draft standard wanted to change it into
       a `size_t *', and that is what it is for SunOS 5.  Later  POSIX  drafts
       have `socklen_t *', and so do the Single Unix Specification and glibc2.
       Quoting Linus Torvalds:

       "_Any_ sane library _must_ have "socklen_t" be the same  size  as  int.
       Anything  else  breaks any BSD socket layer stuff.  POSIX initially did
       make it a size_t, and I (and hopefully others, but  obviously  not  too
       many)  complained  to  them  very loudly indeed.  Making it a size_t is
       completely broken, exactly because size_t very seldom is the same  size
       as  "int"  on  64-bit architectures, for example.  And it has to be the
       same size as "int" because that's what the  BSD  socket  interface  is.
       Anyway,   the   POSIX   people  eventually  got  a  clue,  and  created
       "socklen_t".  They shouldn't have touched it in the  first  place,  but
       once  they  did  they felt it had to have a named type for some unfath-
       omable reason (probably somebody didn't like losing  face  over  having
       done  the  original  stupid  thing, so they silently just renamed their
       blunder)."

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

* Re: [Qemu-devel] [patch] use socklen_t with getsockopt()
  2007-04-06 21:51   ` Mike Frysinger
  2007-04-06 21:59     ` Paul Brook
@ 2007-04-10 10:59     ` Jamie Lokier
  1 sibling, 0 replies; 9+ messages in thread
From: Jamie Lokier @ 2007-04-10 10:59 UTC (permalink / raw)
  To: Mike Frysinger; +Cc: Sylvain Petreolle, qemu-devel

Mike Frysinger wrote:
> On Thursday 05 April 2007, Jamie Lokier wrote:
> > Sylvain Petreolle wrote:
> > > Was incorrect before too, since it was sizeof(int) in the first place ?
> >
> > The old type of "val" was "int", so it made no different to the size.
> > When "val" is of type socklen_t, it matters.
> 
> val is still of type int which is fine ... socklen_t is for the variable which 
> describes the length of val

Yes, thanks for pointing it out.

-- Jamie

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

* [Qemu-devel] [patch] use socklen_t with getsockopt()
@ 2007-06-23 18:27 Mike Frysinger
  0 siblings, 0 replies; 9+ messages in thread
From: Mike Frysinger @ 2007-06-23 18:27 UTC (permalink / raw)
  To: qemu-devel


[-- Attachment #1.1: Type: text/plain, Size: 67 bytes --]

obvious fixup ... getsockopt() takes a socklen_t, not an int
-mike

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 827 bytes --]

[-- Attachment #2: qemu-socklen-t.patch --]
[-- Type: text/x-diff, Size: 1036 bytes --]

--- linux-user/syscall.c
+++ linux-user/syscall.c
@@ -642,7 +642,8 @@ static long do_setsockopt(int sockfd, in
 static long do_getsockopt(int sockfd, int level, int optname, 
                           target_ulong optval, target_ulong optlen)
 {
-    int len, lv, val, ret;
+    int len, val, ret;
+    socklen_t lv;
 
     switch(level) {
     case TARGET_SOL_SOCKET:
@@ -665,7 +666,7 @@ static long do_getsockopt(int sockfd, in
         len = tget32(optlen);
         if (len < 0)
             return -EINVAL;
-        lv = sizeof(int);
+        lv = sizeof(val);
         ret = get_errno(getsockopt(sockfd, level, optname, &val, &lv));
         if (ret < 0)
             return ret;
@@ -698,7 +699,7 @@ static long do_getsockopt(int sockfd, in
             len = tget32(optlen);
             if (len < 0)
                 return -EINVAL;
-            lv = sizeof(int);
+            lv = sizeof(val);
             ret = get_errno(getsockopt(sockfd, level, optname, &val, &lv));
             if (ret < 0)
                 return ret;

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

end of thread, other threads:[~2007-06-23 18:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-05  8:43 Re : [Qemu-devel] [patch] use socklen_t with getsockopt() Sylvain Petreolle
2007-04-05 10:42 ` Jamie Lokier
2007-04-06 21:51   ` Mike Frysinger
2007-04-06 21:59     ` Paul Brook
2007-04-10 10:59     ` Jamie Lokier
  -- strict thread matches above, loose matches on Subject: below --
2007-06-23 18:27 Mike Frysinger
2007-03-31  8:24 Mike Frysinger
2007-04-01 18:43 ` Thiemo Seufer
2007-04-01 22:25   ` Mike Frysinger

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