Protection against stdio functions being implemented as macros.
This appears to be the case for recent glibc when compiling with _FORTIFY_SOURCE. Posix 1003.1-2001, 2.1.2: Any function declared in a header may also be implemented as a macro defined in the header, so a function should not be declared explicitly if its header is included. Any macro definition of a function can be suppressed locally by enclosing the name of the function in parentheses, because the name is then not followed by the left parenthesis that indicates expansion of a macro function name. CVS: ---------------------------------------------------------------------- CVS: Enter Log. Lines beginning with `CVS:' are removed automatically CVS: CVS: Committing in . CVS: CVS: Modified Files: CVS: io.c ioaux.c CVS: ---------------------------------------------------------------------- git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1594 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -208,7 +208,7 @@ uio_mountDir(uio_Repository *destRep, const char *mountPoint,
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert(handler->mount != NULL);
|
assert(handler->mount != NULL);
|
||||||
pRoot = handler->mount(handle, flags);
|
pRoot = (handler->mount)(handle, flags);
|
||||||
if (pRoot == NULL) {
|
if (pRoot == NULL) {
|
||||||
int savedErrno;
|
int savedErrno;
|
||||||
|
|
||||||
@@ -390,7 +390,7 @@ uio_rename(uio_DirHandle *oldDir, const char *oldPath,
|
|||||||
errno = ENOSYS;
|
errno = ENOSYS;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
retVal = oldReadMountInfo->pDirHandle->pRoot->handler->rename(
|
retVal = (oldReadMountInfo->pDirHandle->pRoot->handler->rename)(
|
||||||
oldPReadDir, oldName, newPReadDir, newName);
|
oldPReadDir, oldName, newPReadDir, newName);
|
||||||
if (retVal == -1) {
|
if (retVal == -1) {
|
||||||
int savedErrno = errno;
|
int savedErrno = errno;
|
||||||
@@ -417,7 +417,7 @@ uio_fstat(uio_Handle *handle, struct stat *statBuf) {
|
|||||||
errno = ENOSYS;
|
errno = ENOSYS;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return handle->root->handler->fstat(handle, statBuf);
|
return (handle->root->handler->fstat)(handle, statBuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -444,7 +444,7 @@ uio_stat(uio_DirHandle *dir, const char *path, struct stat *statBuf) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = pReadDir->pRoot->handler->stat(pReadDir, name, statBuf);
|
result = (pReadDir->pRoot->handler->stat)(pReadDir, name, statBuf);
|
||||||
uio_PDirHandle_unref(pReadDir);
|
uio_PDirHandle_unref(pReadDir);
|
||||||
uio_free(name);
|
uio_free(name);
|
||||||
return result;
|
return result;
|
||||||
@@ -506,7 +506,7 @@ uio_statOneDir(uio_PDirHandle *pDirHandle, struct stat *statBuf) {
|
|||||||
errno = ENOSYS;
|
errno = ENOSYS;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return pDirHandle->pRoot->handler->stat(pDirHandle, ".", statBuf);
|
return (pDirHandle->pRoot->handler->stat)(pDirHandle, ".", statBuf);
|
||||||
// sets errno on error
|
// sets errno on error
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -534,7 +534,7 @@ uio_mkdir(uio_DirHandle *dir, const char *path, mode_t mode) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
newDirHandle = pWriteDir->pRoot->handler->mkdir(pWriteDir, name, mode);
|
newDirHandle = (pWriteDir->pRoot->handler->mkdir)(pWriteDir, name, mode);
|
||||||
if (newDirHandle == NULL) {
|
if (newDirHandle == NULL) {
|
||||||
int savedErrno = errno;
|
int savedErrno = errno;
|
||||||
uio_free(name);
|
uio_free(name);
|
||||||
@@ -620,7 +620,7 @@ uio_open(uio_DirHandle *dir, const char *path, int flags, mode_t mode) {
|
|||||||
pDirHandle = writePDirHandle;
|
pDirHandle = writePDirHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
handle = pDirHandle->pRoot->handler->open(pDirHandle, name, flags, mode);
|
handle = (pDirHandle->pRoot->handler->open)(pDirHandle, name, flags, mode);
|
||||||
// Also adds a new entry to the physical dir if appropriate.
|
// Also adds a new entry to the physical dir if appropriate.
|
||||||
if (handle == NULL) {
|
if (handle == NULL) {
|
||||||
int savedErrno = errno;
|
int savedErrno = errno;
|
||||||
@@ -687,7 +687,7 @@ uio_closeDir(uio_DirHandle *dirHandle) {
|
|||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
uio_read(uio_Handle *handle, void *buf, size_t count) {
|
uio_read(uio_Handle *handle, void *buf, size_t count) {
|
||||||
return handle->root->handler->read(handle, buf, count);
|
return (handle->root->handler->read)(handle, buf, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -747,7 +747,7 @@ uio_rmdir(uio_DirHandle *dirHandle, const char *path) {
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pDirHandle->pRoot->handler->rmdir(pDirHandle, name) == -1) {
|
if ((pDirHandle->pRoot->handler->rmdir)(pDirHandle, name) == -1) {
|
||||||
// errno is set
|
// errno is set
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@@ -790,7 +790,7 @@ uio_lseek(uio_Handle *handle, off_t offset, int whence) {
|
|||||||
errno = ENOSYS;
|
errno = ENOSYS;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return handle->root->handler->seek(handle, offset, whence);
|
return (handle->root->handler->seek)(handle, offset, whence);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
@@ -799,7 +799,7 @@ uio_write(uio_Handle *handle, const void *buf, size_t count) {
|
|||||||
errno = ENOSYS;
|
errno = ENOSYS;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return handle->root->handler->write(handle, buf, count);
|
return (handle->root->handler->write)(handle, buf, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
@@ -857,7 +857,7 @@ uio_unlink(uio_DirHandle *dirHandle, const char *path) {
|
|||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pDirHandle->pRoot->handler->unlink(pDirHandle, name) == -1) {
|
if ((pDirHandle->pRoot->handler->unlink)(pDirHandle, name) == -1) {
|
||||||
// errno is set
|
// errno is set
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@@ -1518,7 +1518,7 @@ uio_Handle_new(uio_PRoot *root, uio_NativeHandle native, int openFlags) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
uio_Handle_delete(uio_Handle *handle) {
|
uio_Handle_delete(uio_Handle *handle) {
|
||||||
handle->root->handler->close(handle);
|
(handle->root->handler->close)(handle);
|
||||||
uio_PRoot_unrefHandle(handle->root);
|
uio_PRoot_unrefHandle(handle->root);
|
||||||
uio_Handle_free(handle);
|
uio_Handle_free(handle);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -162,17 +162,17 @@ uio_copyFilePhysical(uio_PDirHandle *fromDir, const char *fromName,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fromHandle = fromHandler->open(fromDir, fromName, O_RDONLY, 0);
|
fromHandle = (fromHandler->open)(fromDir, fromName, O_RDONLY, 0);
|
||||||
if (fromHandle == NULL) {
|
if (fromHandle == NULL) {
|
||||||
// errno is set
|
// errno is set
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fromHandler->fstat(fromHandle, &statBuf) == -1)
|
if ((fromHandler->fstat)(fromHandle, &statBuf) == -1)
|
||||||
return copyError(errno, fromHandler, fromHandle,
|
return copyError(errno, fromHandler, fromHandle,
|
||||||
toHandler, NULL, NULL, NULL, NULL);
|
toHandler, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
toHandle = toHandler->open(toDir, toName, O_WRONLY | O_CREAT | O_EXCL,
|
toHandle = (toHandler->open)(toDir, toName, O_WRONLY | O_CREAT | O_EXCL,
|
||||||
statBuf.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO));
|
statBuf.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO));
|
||||||
if (toHandle == NULL)
|
if (toHandle == NULL)
|
||||||
return copyError(errno, fromHandler, fromHandle,
|
return copyError(errno, fromHandler, fromHandle,
|
||||||
@@ -182,7 +182,7 @@ uio_copyFilePhysical(uio_PDirHandle *fromDir, const char *fromName,
|
|||||||
// not allocated on the stack, as this function may be called
|
// not allocated on the stack, as this function may be called
|
||||||
// from a thread with little stack space.
|
// from a thread with little stack space.
|
||||||
while (1) {
|
while (1) {
|
||||||
numInBuf = fromHandler->read(fromHandle, buf, BUFSIZE);
|
numInBuf = (fromHandler->read)(fromHandle, buf, BUFSIZE);
|
||||||
if (numInBuf == -1)
|
if (numInBuf == -1)
|
||||||
{
|
{
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
@@ -195,7 +195,7 @@ uio_copyFilePhysical(uio_PDirHandle *fromDir, const char *fromName,
|
|||||||
|
|
||||||
bufPtr = buf;
|
bufPtr = buf;
|
||||||
do {
|
do {
|
||||||
numWritten = toHandler->write(toHandle, bufPtr, numInBuf);
|
numWritten = (toHandler->write)(toHandle, bufPtr, numInBuf);
|
||||||
if (numWritten == -1)
|
if (numWritten == -1)
|
||||||
{
|
{
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
@@ -209,8 +209,8 @@ uio_copyFilePhysical(uio_PDirHandle *fromDir, const char *fromName,
|
|||||||
}
|
}
|
||||||
|
|
||||||
uio_free(buf);
|
uio_free(buf);
|
||||||
toHandler->close(toHandle);
|
(toHandler->close)(toHandle);
|
||||||
fromHandler->close(fromHandle);
|
(fromHandler->close)(fromHandle);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,13 +231,13 @@ copyError(int error,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (fromHandle != NULL)
|
if (fromHandle != NULL)
|
||||||
fromHandler->close(fromHandle);
|
(fromHandler->close)(fromHandle);
|
||||||
|
|
||||||
if (toHandle != NULL)
|
if (toHandle != NULL)
|
||||||
toHandler->close(toHandle);
|
(toHandler->close)(toHandle);
|
||||||
|
|
||||||
if (toName != NULL)
|
if (toName != NULL)
|
||||||
toHandler->unlink(toDir, toName);
|
(toHandler->unlink)(toDir, toName);
|
||||||
|
|
||||||
if (buf != NULL)
|
if (buf != NULL)
|
||||||
uio_free(buf);
|
uio_free(buf);
|
||||||
|
|||||||
Reference in New Issue
Block a user