Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Jan 2015 07:10:44 +0000 (UTC)
From:      Dmitry Chagin <dchagin@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r276957 - in stable/9/sys: compat/freebsd32 compat/linux kern sys
Message-ID:  <201501110710.t0B7AiGc041054@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dchagin
Date: Sun Jan 11 07:10:43 2015
New Revision: 276957
URL: https://svnweb.freebsd.org/changeset/base/276957

Log:
  MFC r276564, r276654:
  
  Cast *path to silence clang -Wpointer-sign warning.
  
  Instead of hiding the kern___getcwd() bug by bogus cast
  in r276564, change path type to char * (pathnames are always char *).
  And remove bogus casts of malloc().
  kern___getcwd() internally doesn't actually use or support u_char *
  paths, except to copy them to a normal char * path.
  
  These changes are not visible to libc as libc/gen/getcwd.c misdeclares
  __getcwd() as taking a plain char * path.
  
  While here remove _SYS_SYSPROTO_H_ for __getcwd() syscall as
  we always have sysproto.h.

Modified:
  stable/9/sys/compat/freebsd32/syscalls.master
  stable/9/sys/compat/linux/linux_getcwd.c
  stable/9/sys/kern/syscalls.master
  stable/9/sys/kern/vfs_cache.c
  stable/9/sys/sys/syscallsubr.h
Directory Properties:
  stable/9/   (props changed)
  stable/9/sys/   (props changed)
  stable/9/sys/sys/   (props changed)

Modified: stable/9/sys/compat/freebsd32/syscalls.master
==============================================================================
--- stable/9/sys/compat/freebsd32/syscalls.master	Sun Jan 11 07:04:18 2015	(r276956)
+++ stable/9/sys/compat/freebsd32/syscalls.master	Sun Jan 11 07:10:43 2015	(r276957)
@@ -580,7 +580,7 @@
 323	AUE_NULL	OBSOL	thr_wakeup
 324	AUE_MLOCKALL	NOPROTO	{ int mlockall(int how); }
 325	AUE_MUNLOCKALL	NOPROTO	{ int munlockall(void); }
-326	AUE_GETCWD	NOPROTO	{ int __getcwd(u_char *buf, u_int buflen); }
+326	AUE_GETCWD	NOPROTO	{ int __getcwd(char *buf, u_int buflen); }
 
 327	AUE_NULL	NOPROTO	{ int sched_setparam (pid_t pid, \
 				    const struct sched_param *param); }

Modified: stable/9/sys/compat/linux/linux_getcwd.c
==============================================================================
--- stable/9/sys/compat/linux/linux_getcwd.c	Sun Jan 11 07:04:18 2015	(r276956)
+++ stable/9/sys/compat/linux/linux_getcwd.c	Sun Jan 11 07:10:43 2015	(r276957)
@@ -186,7 +186,7 @@ linux_getcwd_scandir(lvpp, uvpp, bpp, bu
 	dirbuflen = DIRBLKSIZ;
 	if (dirbuflen < va.va_blocksize)
 		dirbuflen = va.va_blocksize;
-	dirbuf = (char *)malloc(dirbuflen, M_TEMP, M_WAITOK);
+	dirbuf = malloc(dirbuflen, M_TEMP, M_WAITOK);
 
 #if 0
 unionread:
@@ -413,7 +413,7 @@ out:
 int
 linux_getcwd(struct thread *td, struct linux_getcwd_args *args)
 {
-	caddr_t bp, bend, path;
+	char *bp, *bend, *path;
 	int error, len, lenused;
 
 #ifdef DEBUG
@@ -428,7 +428,7 @@ linux_getcwd(struct thread *td, struct l
 	else if (len < 2)
 		return ERANGE;
 
-	path = (char *)malloc(len, M_TEMP, M_WAITOK);
+	path = malloc(len, M_TEMP, M_WAITOK);
 
 	error = kern___getcwd(td, path, UIO_SYSSPACE, len);
 	if (!error) {

Modified: stable/9/sys/kern/syscalls.master
==============================================================================
--- stable/9/sys/kern/syscalls.master	Sun Jan 11 07:04:18 2015	(r276956)
+++ stable/9/sys/kern/syscalls.master	Sun Jan 11 07:10:43 2015	(r276957)
@@ -569,7 +569,7 @@
 323	AUE_NULL	OBSOL	thr_wakeup
 324	AUE_MLOCKALL	STD	{ int mlockall(int how); }
 325	AUE_MUNLOCKALL	STD	{ int munlockall(void); }
-326	AUE_GETCWD	STD	{ int __getcwd(u_char *buf, u_int buflen); }
+326	AUE_GETCWD	STD	{ int __getcwd(char *buf, u_int buflen); }
 
 327	AUE_NULL	STD	{ int sched_setparam (pid_t pid, \
 				    const struct sched_param *param); }

Modified: stable/9/sys/kern/vfs_cache.c
==============================================================================
--- stable/9/sys/kern/vfs_cache.c	Sun Jan 11 07:04:18 2015	(r276956)
+++ stable/9/sys/kern/vfs_cache.c	Sun Jan 11 07:10:43 2015	(r276957)
@@ -1044,14 +1044,6 @@ vfs_cache_lookup(ap)
 	return (error);
 }
 
-
-#ifndef _SYS_SYSPROTO_H_
-struct  __getcwd_args {
-	u_char	*buf;
-	u_int	buflen;
-};
-#endif
-
 /*
  * XXX All of these sysctls would probably be more productive dead.
  */
@@ -1070,7 +1062,7 @@ sys___getcwd(td, uap)
 }
 
 int
-kern___getcwd(struct thread *td, u_char *buf, enum uio_seg bufseg, u_int buflen)
+kern___getcwd(struct thread *td, char *buf, enum uio_seg bufseg, u_int buflen)
 {
 	char *bp, *tmpbuf;
 	struct filedesc *fdp;

Modified: stable/9/sys/sys/syscallsubr.h
==============================================================================
--- stable/9/sys/sys/syscallsubr.h	Sun Jan 11 07:04:18 2015	(r276956)
+++ stable/9/sys/sys/syscallsubr.h	Sun Jan 11 07:10:43 2015	(r276957)
@@ -56,7 +56,7 @@ struct stat;
 struct thr_param;
 struct __wrusage;
 
-int	kern___getcwd(struct thread *td, u_char *buf, enum uio_seg bufseg,
+int	kern___getcwd(struct thread *td, char *buf, enum uio_seg bufseg,
 	    u_int buflen);
 int	kern_accept(struct thread *td, int s, struct sockaddr **name,
 	    socklen_t *namelen, struct file **fp);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201501110710.t0B7AiGc041054>