From 2f7a952cc6fc23b73d3bcba0c50f5ae7c6400488 Mon Sep 17 00:00:00 2001 From: Chad Elliott Date: Mon, 10 Jun 2019 06:19:15 -0500 Subject: Added static cast where pid_t is assumed to be an int. Replaced NULL usage. Removed trailing whitespace. Used ACE_NOTSUP_RETURN in ace_fileno_helper(). Removed $Id$ from platform_mqx_icc.GNU. --- ACE/ace/ACE.cpp | 2 +- ACE/ace/MQX_Filesystem.cpp | 70 ++++++++++++++-------------- ACE/ace/MQX_Filesystem.h | 2 +- ACE/ace/OS_NS_stdio.h | 3 +- ACE/include/makeinclude/platform_mqx_icc.GNU | 2 - 5 files changed, 39 insertions(+), 40 deletions(-) diff --git a/ACE/ace/ACE.cpp b/ACE/ace/ACE.cpp index 7a26dff2913..bc2cc405335 100644 --- a/ACE/ace/ACE.cpp +++ b/ACE/ace/ACE.cpp @@ -2793,7 +2793,7 @@ ACE::fork (const ACE_TCHAR *program_name, { case 0: // grandchild returns 0. return 0; - case -1: // assumes all errnos are < 256 + case static_cast(-1): // assumes all errnos are < 256 ACE_OS::_exit (errno); default: // child terminates, orphaning grandchild ACE_OS::_exit (0); diff --git a/ACE/ace/MQX_Filesystem.cpp b/ACE/ace/MQX_Filesystem.cpp index 3bdbe3cfb31..f04303d8675 100644 --- a/ACE/ace/MQX_Filesystem.cpp +++ b/ACE/ace/MQX_Filesystem.cpp @@ -23,7 +23,7 @@ MQX_Filesystem MQX_Filesystem::instance_; MQX_Filesystem::MQX_Filesystem () - : current_fs_ (NULL) + : current_fs_ (0) , current_fs_name_len_ (0) , max_fd_ (255) , last_fd_ (-1) @@ -34,7 +34,7 @@ MQX_Filesystem::MQX_Filesystem () for (unsigned i = 0; i < FOPEN_MAX; i++) { files_[i].fd = -1; - files_[i].mqx_file = NULL; + files_[i].mqx_file = 0; } } @@ -71,9 +71,9 @@ bool MQX_Filesystem::reset_state () { update_fs (_io_get_first_valid_fs ()); - if (current_fs_ != NULL) + if (current_fs_ != 0) chdir ("\\"); - return current_fs_ == NULL; + return current_fs_ == 0; } void @@ -81,7 +81,7 @@ MQX_Filesystem::update_fs (MQX_FILE_PTR fs) { current_fs_ = fs; bool invalid = false; - if (fs == NULL) + if (fs == 0) invalid = true; else if (_io_get_fs_name (fs, current_fs_name_, IOCFG_FS_MAX_DEVLEN) != MQX_OK) invalid = true; @@ -90,7 +90,7 @@ MQX_Filesystem::update_fs (MQX_FILE_PTR fs) if (invalid) { - current_fs_ = NULL; + current_fs_ = 0; current_fs_name_[0] = '\0'; current_fs_name_len_ = 0; } @@ -135,11 +135,11 @@ MQX_Filesystem::open (const char *path, int mode) // Set up a new File Entry File *file = get_new_file (); - if (file == NULL) return -1; + if (file == 0) return -1; // Call into MQX file->mqx_file = _io_fopen (abspath, cstdlib_mode); - if (file->mqx_file == NULL) + if (file->mqx_file == 0) { file->fd = -1; // Free File in Our Array errno = ACE_OS::mqx_error_to_errno (_task_get_error()); @@ -154,7 +154,7 @@ int MQX_Filesystem::close (int fd) { File *file = get_file (fd); - if (file == NULL) return -1; + if (file == 0) return -1; int mqx_error = _io_fclose (file->mqx_file); if (mqx_error != MQX_OK) { @@ -168,7 +168,7 @@ size_t MQX_Filesystem::read (int fd, unsigned char *buffer, size_t size) { File *file = get_file (fd); - if (file == NULL) return MQX_FILE_ERROR; + if (file == 0) return MQX_FILE_ERROR; int result = _io_read (file->mqx_file, buffer, size); if (result == IO_ERROR) { @@ -182,7 +182,7 @@ size_t MQX_Filesystem::write (int fd, const unsigned char *buffer, size_t size) { File *file = get_file (fd); - if (file == NULL) return MQX_FILE_ERROR; + if (file == 0) return MQX_FILE_ERROR; int result = _io_write (file->mqx_file, const_cast (buffer), size); if (result == IO_ERROR) { @@ -211,18 +211,18 @@ MQX_Filesystem::lseek (int fd, long offset, int whence) return -1; } File *file = get_file (fd); - if (file == NULL) return -1; + if (file == 0) return -1; return _io_fseek (file->mqx_file, offset, whence) == MQX_OK ? 0 : -1; } char* MQX_Filesystem::getcwd (char *buf, size_t size) { - if (check_state ()) return NULL; - if (buf == NULL) + if (check_state ()) return 0; + if (buf == 0) { errno = EINVAL; - return NULL; + return 0; } char curdirtmp[FS_FILENAME_SIZE]; @@ -230,12 +230,12 @@ MQX_Filesystem::getcwd (char *buf, size_t size) if (mqx_error != MFS_NO_ERROR) { errno = ACE_OS::mqx_error_to_errno (mqx_error); - return NULL; + return 0; } if ((current_fs_name_len_ + strlen (curdirtmp) + 1) > size) { errno = ERANGE; - return NULL; + return 0; } strcpy (buf, current_fs_name_); strcat (buf, curdirtmp); @@ -245,12 +245,12 @@ MQX_Filesystem::getcwd (char *buf, size_t size) MQX_FILE_PTR MQX_Filesystem::resolve_fs (const char *path, int *fs_name_len) { - if (check_state ()) return NULL; + if (check_state ()) return 0; - if (fs_name_len == NULL || path == NULL || path[0] == '\0') + if (fs_name_len == 0 || path == 0 || path[0] == '\0') { errno = EINVAL; - return NULL; + return 0; } MQX_FILE_PTR fs; char fs_name[IOCFG_FS_MAX_DEVLEN]; @@ -269,7 +269,7 @@ MQX_Filesystem::resolve_fs (const char *path, int *fs_name_len) else { errno = EINVAL; - fs = NULL; + fs = 0; } return fs; } @@ -279,7 +279,7 @@ MQX_Filesystem::mkdir (const char *path) { int fs_name_len; MQX_FILE_PTR fs = resolve_fs (path, &fs_name_len); - if (fs == NULL) return -1; + if (fs == 0) return -1; int mqx_error = _io_ioctl ( fs, IO_IOCTL_CREATE_SUBDIR, (uint32_t*) (path + fs_name_len)); if (mqx_error != MQX_OK) @@ -295,7 +295,7 @@ MQX_Filesystem::chdir (const char *path) { int fs_name_len; MQX_FILE_PTR fs = resolve_fs (path, &fs_name_len); - if (fs == NULL) return -1; + if (fs == 0) return -1; if (fs != current_fs_) update_fs(fs); int mqx_error = _io_ioctl (fs, IO_IOCTL_CHANGE_CURRENT_DIR, (uint32_t*) (path + fs_name_len)); @@ -312,7 +312,7 @@ MQX_Filesystem::rmdir (const char *path) { int fs_name_len; MQX_FILE_PTR fs = resolve_fs (path, &fs_name_len); - if (fs == NULL) return -1; + if (fs == 0) return -1; int mqx_error = _io_ioctl (fs, IO_IOCTL_REMOVE_SUBDIR, (uint32_t*) (path + fs_name_len)); if (mqx_error != MQX_OK) @@ -328,7 +328,7 @@ MQX_Filesystem::unlink (const char *path) { int fs_name_len; MQX_FILE_PTR fs = resolve_fs (path, &fs_name_len); - if (fs == NULL) return -1; + if (fs == 0) return -1; int mqx_error = _io_ioctl (fs, IO_IOCTL_DELETE_FILE, (uint32_t*) (path + fs_name_len)); if (mqx_error != MQX_OK) @@ -347,7 +347,7 @@ MQX_Filesystem::rename (const char *oldpath, const char *newpath) MQX_FILE_PTR fs = resolve_fs (oldpath, &old_fs_name_len); int new_fs_name_len; MQX_FILE_PTR other_fs = resolve_fs (newpath, &new_fs_name_len); - if (fs == NULL || other_fs == NULL) return -1; + if (fs == 0 || other_fs == 0) return -1; if (fs != other_fs) { errno = EXDEV; @@ -405,7 +405,7 @@ MQX_Filesystem::get_file (int fd) if (files_[i].fd == fd) return &files_[i]; } errno = EBADF; - return NULL; + return 0; } MQX_Filesystem::File * @@ -413,13 +413,13 @@ MQX_Filesystem::get_new_file () { // Get Unused File Struct File *file = get_file (-1); - if (file != NULL) + if (file != 0) { - file->mqx_file = NULL; + file->mqx_file = 0; // Get Unused File Descriptor for (int fd = last_fd_ + 1; fd != last_fd_; fd++) { - if (get_file (fd) == NULL) + if (get_file (fd) == 0) { file->fd = fd; last_fd_ = fd; @@ -429,7 +429,7 @@ MQX_Filesystem::get_new_file () } } errno = ENFILE; - return NULL; + return 0; } static inline int @@ -442,7 +442,7 @@ mfs_file_attrs_to_stat_mode (int attributes) int MQX_Filesystem::stat (const char * path, ACE_stat *statbuf) { - if (statbuf == NULL) + if (statbuf == 0) { errno = EINVAL; return -1; @@ -450,7 +450,7 @@ MQX_Filesystem::stat (const char * path, ACE_stat *statbuf) int fs_name_len; MQX_FILE_PTR fs = resolve_fs (path, &fs_name_len); - if (fs == NULL) return -1; + if (fs == 0) return -1; statbuf->st_size = 0; statbuf->st_mtime = 0; @@ -480,14 +480,14 @@ MQX_Filesystem::stat (const char * path, ACE_stat *statbuf) int MQX_Filesystem::fstat (int fd, ACE_stat *statbuf) { - if (statbuf == NULL) + if (statbuf == 0) { errno = EINVAL; return -1; } File *file = get_file (fd); - if (file == NULL) return -1; + if (file == 0) return -1; statbuf->st_size = 0; statbuf->st_mtime = 0; diff --git a/ACE/ace/MQX_Filesystem.h b/ACE/ace/MQX_Filesystem.h index 70953945479..2bc32cb24a4 100644 --- a/ACE/ace/MQX_Filesystem.h +++ b/ACE/ace/MQX_Filesystem.h @@ -22,7 +22,7 @@ # undef read # undef write #endif - + struct stat; typedef struct stat ACE_stat; diff --git a/ACE/ace/OS_NS_stdio.h b/ACE/ace/OS_NS_stdio.h index d9a73a7bddf..a7705077d04 100644 --- a/ACE/ace/OS_NS_stdio.h +++ b/ACE/ace/OS_NS_stdio.h @@ -26,6 +26,7 @@ #include "ace/os_include/os_stdio.h" #include "ace/os_include/os_fcntl.h" #include "ace/os_include/os_inttypes.h" +#include "ace/os_include/os_errno.h" #include /**/ "ace/ACE_export.h" /* OPENVMS needs unistd for cuserid() */ @@ -128,7 +129,7 @@ inline ACE_HANDLE ace_fileno_helper (FILE *fp) # undef fileno # elif defined (ACE_LACKS_FILENO) ACE_UNUSED_ARG (fp); - return ACE_INVALID_HANDLE; + ACE_NOTSUP_RETURN (ACE_INVALID_HANDLE); # else return (ACE_HANDLE)(intptr_t)ACE_STD_NAMESPACE::fileno (fp); # endif /* defined (fileno) */ diff --git a/ACE/include/makeinclude/platform_mqx_icc.GNU b/ACE/include/makeinclude/platform_mqx_icc.GNU index 4f0716d00c4..7d5559b384a 100644 --- a/ACE/include/makeinclude/platform_mqx_icc.GNU +++ b/ACE/include/makeinclude/platform_mqx_icc.GNU @@ -1,5 +1,3 @@ -# $Id$ - # This file should allow ACE to be built on Windows, using the IAR compiler. MQX_CPU = PSP_CPU_MK70F120M -- cgit v1.2.1