Commit 2b8bdefc3a35473e1d43c22e6201aad900dccad2

Authored by ths
1 parent 7b717336

Sync __target_cmsg_nxthdr implementation with kernel header.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2894 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 7 additions and 12 deletions
linux-user/syscall_defs.h
@@ -176,19 +176,14 @@ struct target_cmsghdr { @@ -176,19 +176,14 @@ struct target_cmsghdr {
176 static __inline__ struct target_cmsghdr * 176 static __inline__ struct target_cmsghdr *
177 __target_cmsg_nxthdr (struct target_msghdr *__mhdr, struct target_cmsghdr *__cmsg) 177 __target_cmsg_nxthdr (struct target_msghdr *__mhdr, struct target_cmsghdr *__cmsg)
178 { 178 {
179 - if (tswapl(__cmsg->cmsg_len) < sizeof (struct target_cmsghdr))  
180 - /* The kernel header does this so there may be a reason. */  
181 - return 0;  
182 -  
183 - __cmsg = (struct target_cmsghdr *) ((unsigned char *) __cmsg  
184 - + TARGET_CMSG_ALIGN (tswapl(__cmsg->cmsg_len)));  
185 - if ((unsigned char *) (__cmsg + 1) > ((unsigned char *) (unsigned long)tswapl(__mhdr->msg_control)  
186 - + tswapl(__mhdr->msg_controllen))  
187 - || ((unsigned char *) __cmsg + TARGET_CMSG_ALIGN (tswapl(__cmsg->cmsg_len))  
188 - > ((unsigned char *) (unsigned long) tswapl(__mhdr->msg_control)  
189 - + tswapl(__mhdr->msg_controllen)))) 179 + struct target_cmsghdr *__ptr;
  180 +
  181 + __ptr = (struct target_cmsghdr *)((unsigned char *) __cmsg
  182 + + TARGET_CMSG_ALIGN (tswapl(__cmsg->cmsg_len)));
  183 + if ((unsigned long)((char *)(__ptr+1) - (char *)(size_t)tswapl(__mhdr->msg_control))
  184 + > tswapl(__mhdr->msg_controllen))
190 /* No more entries. */ 185 /* No more entries. */
191 - return 0; 186 + return (struct target_cmsghdr *)0;
192 return __cmsg; 187 return __cmsg;
193 } 188 }
194 189