Skip to content

Commit d0ebfb4

Browse files
authored
Merge pull request #950 from skliper/fix932-identifer-collisions
Fix #932, Eliminate time and access name collisions with VxWorks
2 parents b37da18 + 3962c15 commit d0ebfb4

File tree

10 files changed

+43
-73
lines changed

10 files changed

+43
-73
lines changed

src/os/inc/osapi-file.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -127,16 +127,16 @@ typedef enum
127127
* of outputting the ID/descriptor separately from the return value, rather
128128
* than relying on the user to convert it back.
129129
*
130-
* @param[out] filedes The handle ID (OS_OBJECT_ID_UNDEFINED on failure)
131-
* @param[in] path File name to create or open
132-
* @param[in] flags The file permissions - see @ref OS_file_flag_t
133-
* @param[in] access Intended access mode - see @ref OSFileAccess
130+
* @param[out] filedes The handle ID (OS_OBJECT_ID_UNDEFINED on failure)
131+
* @param[in] path File name to create or open
132+
* @param[in] flags The file permissions - see @ref OS_file_flag_t
133+
* @param[in] access_mode Intended access mode - see @ref OSFileAccess
134134
*
135135
* @return Execution status, see @ref OSReturnCodes
136136
* @retval #OS_SUCCESS @copybrief OS_SUCCESS
137137
* @retval #OS_ERROR if the command was not executed properly
138138
*/
139-
int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 access);
139+
int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 access_mode);
140140

141141
/*-------------------------------------------------------------------------------------*/
142142
/**
@@ -261,14 +261,14 @@ int32 OS_TimedWrite(osal_id_t filedes, const void *buffer, size_t nbytes, int32
261261
/**
262262
* @brief Changes the permissions of a file
263263
*
264-
* @param[in] path File to change
265-
* @param[in] access Desired access mode - see @ref OSFileAccess
264+
* @param[in] path File to change
265+
* @param[in] access_mode Desired access mode - see @ref OSFileAccess
266266
*
267267
* @note Some file systems do not implement permissions
268268
*
269269
* @return Execution status, see @ref OSReturnCodes
270270
*/
271-
int32 OS_chmod(const char *path, uint32 access);
271+
int32 OS_chmod(const char *path, uint32 access_mode);
272272

273273
/*-------------------------------------------------------------------------------------*/
274274
/**

src/os/portable/os-impl-posix-files.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
* See prototype for argument/return detail
6868
*
6969
*-----------------------------------------------------------------*/
70-
int32 OS_FileOpen_Impl(const OS_object_token_t *token, const char *local_path, int32 flags, int32 access)
70+
int32 OS_FileOpen_Impl(const OS_object_token_t *token, const char *local_path, int32 flags, int32 access_mode)
7171
{
7272
int os_perm;
7373
int os_mode;
@@ -79,7 +79,7 @@ int32 OS_FileOpen_Impl(const OS_object_token_t *token, const char *local_path, i
7979
** Check for a valid access mode
8080
** For creating a file, OS_READ_ONLY does not make sense
8181
*/
82-
switch (access)
82+
switch (access_mode)
8383
{
8484
case OS_WRITE_ONLY:
8585
os_perm = O_WRONLY;
@@ -223,7 +223,7 @@ int32 OS_FileStat_Impl(const char *local_path, os_fstat_t *FileStats)
223223
* See prototype for argument/return detail
224224
*
225225
*-----------------------------------------------------------------*/
226-
int32 OS_FileChmod_Impl(const char *local_path, uint32 access)
226+
int32 OS_FileChmod_Impl(const char *local_path, uint32 access_mode)
227227
{
228228
mode_t readbits;
229229
mode_t writebits;
@@ -282,7 +282,7 @@ int32 OS_FileChmod_Impl(const char *local_path, uint32 access)
282282
writebits |= S_IWGRP;
283283
}
284284

285-
if (access == OS_WRITE_ONLY || access == OS_READ_WRITE)
285+
if (access_mode == OS_WRITE_ONLY || access_mode == OS_READ_WRITE)
286286
{
287287
/* set all "write" mode bits */
288288
st.st_mode |= writebits;
@@ -293,7 +293,7 @@ int32 OS_FileChmod_Impl(const char *local_path, uint32 access)
293293
st.st_mode &= ~writebits;
294294
}
295295

296-
if (access == OS_READ_ONLY || access == OS_READ_WRITE)
296+
if (access_mode == OS_READ_ONLY || access_mode == OS_READ_WRITE)
297297
{
298298
/* set all "read" mode bits */
299299
st.st_mode |= readbits;

src/os/portable/os-impl-posix-gettime.c

+7-7
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,13 @@ int32 OS_GetLocalTime_Impl(OS_time_t *time_struct)
7373
{
7474
int Status;
7575
int32 ReturnCode;
76-
struct timespec time;
76+
struct timespec TimeSp;
7777

78-
Status = clock_gettime(OSAL_GETTIME_SOURCE_CLOCK, &time);
78+
Status = clock_gettime(OSAL_GETTIME_SOURCE_CLOCK, &TimeSp);
7979

8080
if (Status == 0)
8181
{
82-
*time_struct = OS_TimeAssembleFromNanoseconds(time.tv_sec, time.tv_nsec);
82+
*time_struct = OS_TimeAssembleFromNanoseconds(TimeSp.tv_sec, TimeSp.tv_nsec);
8383
ReturnCode = OS_SUCCESS;
8484
}
8585
else
@@ -103,12 +103,12 @@ int32 OS_SetLocalTime_Impl(const OS_time_t *time_struct)
103103
{
104104
int Status;
105105
int32 ReturnCode;
106-
struct timespec time;
106+
struct timespec TimeSp;
107107

108-
time.tv_sec = OS_TimeGetTotalSeconds(*time_struct);
109-
time.tv_nsec = OS_TimeGetNanosecondsPart(*time_struct);
108+
TimeSp.tv_sec = OS_TimeGetTotalSeconds(*time_struct);
109+
TimeSp.tv_nsec = OS_TimeGetNanosecondsPart(*time_struct);
110110

111-
Status = clock_settime(OSAL_GETTIME_SOURCE_CLOCK, &time);
111+
Status = clock_settime(OSAL_GETTIME_SOURCE_CLOCK, &TimeSp);
112112

113113
if (Status == 0)
114114
{

src/os/shared/inc/os-shared-file.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ int32 OS_GenericClose_Impl(const OS_object_token_t *token);
115115
Function: OS_FileOpen_Impl
116116
117117
Purpose: Opens the file indicated by "local_path" with permission
118-
indicated by "access".
118+
indicated by "access_mode".
119119
120120
Returns: OS_SUCCESS on success, or relevant error code
121121
------------------------------------------------------------------*/
122-
int32 OS_FileOpen_Impl(const OS_object_token_t *token, const char *local_path, int32 flags, int32 access);
122+
int32 OS_FileOpen_Impl(const OS_object_token_t *token, const char *local_path, int32 flags, int32 access_mode);
123123

124124
/*----------------------------------------------------------------
125125
Function: OS_ShellOutputToFile_Impl
@@ -181,7 +181,7 @@ int32 OS_FileRename_Impl(const char *old_path, const char *new_path);
181181
182182
Returns: OS_SUCCESS on success, or relevant error code
183183
------------------------------------------------------------------*/
184-
int32 OS_FileChmod_Impl(const char *local_path, uint32 access);
184+
int32 OS_FileChmod_Impl(const char *local_path, uint32 access_mode);
185185

186186
/*
187187
* Internal helper function

src/os/shared/src/osapi-file.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ int32 OS_FileAPI_Init(void)
110110
* See description in API and header file for detail
111111
*
112112
*-----------------------------------------------------------------*/
113-
int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 access)
113+
int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 access_mode)
114114
{
115115
int32 return_code;
116116
char local_path[OS_MAX_LOCAL_PATH_LEN];
@@ -126,7 +126,7 @@ int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 acc
126126
/*
127127
** Check for a valid access mode
128128
*/
129-
if (access != OS_WRITE_ONLY && access != OS_READ_ONLY && access != OS_READ_WRITE)
129+
if (access_mode != OS_WRITE_ONLY && access_mode != OS_READ_ONLY && access_mode != OS_READ_WRITE)
130130
{
131131
return OS_ERROR;
132132
}
@@ -148,7 +148,7 @@ int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 acc
148148
OS_OBJECT_INIT(token, stream, stream_name, path);
149149

150150
/* Now call the OS-specific implementation. */
151-
return_code = OS_FileOpen_Impl(&token, local_path, flags, access);
151+
return_code = OS_FileOpen_Impl(&token, local_path, flags, access_mode);
152152

153153
/* Check result, finalize record, and unlock global table. */
154154
return_code = OS_ObjectIdFinalizeNew(return_code, &token, filedes);
@@ -274,15 +274,15 @@ int32 OS_write(osal_id_t filedes, const void *buffer, size_t nbytes)
274274
* See description in API and header file for detail
275275
*
276276
*-----------------------------------------------------------------*/
277-
int32 OS_chmod(const char *path, uint32 access)
277+
int32 OS_chmod(const char *path, uint32 access_mode)
278278
{
279279
char local_path[OS_MAX_LOCAL_PATH_LEN];
280280
int32 return_code;
281281

282282
return_code = OS_TranslatePath(path, local_path);
283283
if (return_code == OS_SUCCESS)
284284
{
285-
return_code = OS_FileChmod_Impl(local_path, access);
285+
return_code = OS_FileChmod_Impl(local_path, access_mode);
286286
}
287287

288288
return return_code;

src/unit-test-coverage/portable/src/coveragetest-posix-files.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ void Test_OS_FileOpen_Impl(void)
4141
{
4242
/*
4343
* Test Case For:
44-
* int32 OS_FileOpen_Impl(uint32 local_id, const char *local_path, int32 flags, int32 access)
44+
* int32 OS_FileOpen_Impl(uint32 local_id, const char *local_path, int32 flags, int32 access_mode)
4545
*/
4646
OS_object_token_t token;
4747

@@ -101,7 +101,7 @@ void Test_OS_FileChmod_Impl(void)
101101
{
102102
/*
103103
* Test Case For:
104-
* int32 OS_FileChmod_Impl(const char *local_path, uint32 access)
104+
* int32 OS_FileChmod_Impl(const char *local_path, uint32 access_mode)
105105
*/
106106
struct OCS_stat RefStat;
107107

src/unit-test-coverage/shared/src/coveragetest-file.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void Test_OS_OpenCreate(void)
5252
{
5353
/*
5454
* Test Case For:
55-
* int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 access)
55+
* int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 access_mode)
5656
*/
5757
int32 expected;
5858
int32 actual;
@@ -179,7 +179,7 @@ void Test_OS_chmod(void)
179179
{
180180
/*
181181
* Test Case For:
182-
* int32 OS_chmod (const char *path, uint32 access)
182+
* int32 OS_chmod (const char *path, uint32 access_mode)
183183
*/
184184
int32 expected = OS_SUCCESS;
185185
int32 actual = OS_chmod("/cf/file", 0);

src/unit-test-coverage/ut-stubs/src/osapi-file-impl-stubs.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,18 @@
3939
* File API abstraction layer
4040
*/
4141

42-
UT_DEFAULT_STUB(OS_FileOpen_Impl, (const OS_object_token_t *token, const char *local_path, int32 flags, int32 access))
42+
UT_DEFAULT_STUB(OS_FileOpen_Impl,
43+
(const OS_object_token_t *token, const char *local_path, int32 flags, int32 access_mode))
4344
UT_DEFAULT_STUB(OS_FileStat_Impl, (const char *local_path, os_fstat_t *filestat))
4445
UT_DEFAULT_STUB(OS_FileRemove_Impl, (const char *local_path))
4546
UT_DEFAULT_STUB(OS_FileRename_Impl, (const char *old_path, const char *new_path))
46-
UT_DEFAULT_STUB(OS_FileChmod_Impl, (const char *local_path, uint32 access))
47+
UT_DEFAULT_STUB(OS_FileChmod_Impl, (const char *local_path, uint32 access_mode))
4748
UT_DEFAULT_STUB(OS_ShellOutputToFile_Impl, (const OS_object_token_t *token, const char *Cmd))
4849

4950
/*
5051
* Directory API abstraction layer
5152
*/
52-
UT_DEFAULT_STUB(OS_DirCreate_Impl, (const char *local_path, uint32 access))
53+
UT_DEFAULT_STUB(OS_DirCreate_Impl, (const char *local_path, uint32 access_mode))
5354
UT_DEFAULT_STUB(OS_DirOpen_Impl, (const OS_object_token_t *token, const char *local_path))
5455
UT_DEFAULT_STUB(OS_DirClose_Impl, (const OS_object_token_t *token))
5556
UT_DEFAULT_STUB(OS_DirRead_Impl, (const OS_object_token_t *token, os_dirent_t *dirent))

src/unit-tests/osfile-test/ut_osfile_fileio_test.c

+3-34
Original file line numberDiff line numberDiff line change
@@ -136,20 +136,7 @@ void UT_os_initfs_test()
136136
}
137137

138138
/*--------------------------------------------------------------------------------*
139-
** Syntax: int32 OS_creat(const char *path, int32 access)
140-
** Purpose: Creates a file of a given name and access mode, if doesn't exist;
141-
** then opens it
142-
** Parameters: *path - pointer to the absolute path name of the file to be created
143-
** access - access modes with which to open a file
144-
** Returns: OS_INVALID_POINTER if the pointer passed in is null
145-
** OS_FS_ERR_PATH_INVALID is the path passed in is invalid
146-
** OS_FS_ERR_PATH_TOO_LONG if the absolute path name passed in is too long
147-
** OS_FS_ERR_NAME_TOO_LONG if the file name passed in is too long
148-
** OS_ERROR if the OS call failed or file access is invalid
149-
** OS_FS_ERR_NO_FREE_IDS if there are no more free file descriptors left in
150-
** the File Descriptor table
151-
** A file descriptor value if succeeded
152-
** OS_ERR_NOT_IMPLEMENTED if not implemented
139+
** Purpose: Test OS_OpenCreate for creating files
153140
** -----------------------------------------------------
154141
** Test #0: Not-implemented condition
155142
** 1) Call this routine
@@ -323,21 +310,7 @@ void UT_os_createfile_test()
323310
}
324311

325312
/*--------------------------------------------------------------------------------*
326-
** Syntax: int32 OS_open(const char *path, int32 access, uint32 mode)
327-
** Purpose: Opens a file of a given name and access mode; if it doesn't exist,
328-
** creates it first
329-
** Parameters: *path - pointer to the absolute path name of the file to be created
330-
** access - access modes with which to open a file
331-
** mode - file permission which is not currently used
332-
** Returns: OS_INVALID_POINTER if the pointer passed in is null
333-
** OS_FS_ERR_PATH_INVALID is the path passed in is invalid
334-
** OS_FS_ERR_PATH_TOO_LONG if the absolute path name passed in is too long
335-
** OS_FS_ERR_NAME_TOO_LONG if the file name passed in is too long
336-
** OS_ERROR if the OS call failed or file access is invalid
337-
** OS_FS_ERR_NO_FREE_IDS if there are no more free file descriptors left in
338-
** the File Descriptor table
339-
** A file descriptor value if succeeded
340-
** OS_ERR_NOT_IMPLEMENTED if not implemented
313+
** Purpose: Tests OS_OpenCreate for opening files
341314
** -----------------------------------------------------
342315
** Test #0: Not-implemented condition
343316
** 1) Call this routine
@@ -1129,11 +1102,7 @@ void UT_os_lseekfile_test()
11291102
}
11301103

11311104
/*--------------------------------------------------------------------------------*
1132-
** Syntax: int32 OS_chmod(const char *path, uint32 access)
1133-
** Purpose: Changes access mode of a given file name
1134-
** Parameters: *path - pointer to the path/name of the given file
1135-
** access - file access flags
1136-
** Returns: OS_ERR_NOT_IMPLEMENTED if not implemented
1105+
** Purpose: Test OS_chmod
11371106
** -----------------------------------------------------
11381107
** Test #0: Not-implemented condition
11391108
** 1) Call this routine

src/ut-stubs/osapi-utstub-file.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ static int32 UT_GenericWriteStub(const char *fname, UT_EntryKey_t fkey, const vo
113113
* Stub function for OS_OpenCreate()
114114
*
115115
*****************************************************************************/
116-
int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 access)
116+
int32 OS_OpenCreate(osal_id_t *filedes, const char *path, int32 flags, int32 access_mode)
117117
{
118118
UT_Stub_RegisterContext(UT_KEY(OS_OpenCreate), filedes);
119119
UT_Stub_RegisterContext(UT_KEY(OS_OpenCreate), path);
120120
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_OpenCreate), flags);
121-
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_OpenCreate), access);
121+
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_OpenCreate), access_mode);
122122
int32 status;
123123

124124
status = UT_DEFAULT_IMPL(OS_OpenCreate);
@@ -238,10 +238,10 @@ int32 OS_TimedWrite(osal_id_t filedes, const void *buffer, size_t nbytes, int32
238238
* Stub function for OS_chmod()
239239
*
240240
*****************************************************************************/
241-
int32 OS_chmod(const char *path, uint32 access)
241+
int32 OS_chmod(const char *path, uint32 access_mode)
242242
{
243243
UT_Stub_RegisterContext(UT_KEY(OS_chmod), path);
244-
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_chmod), access);
244+
UT_Stub_RegisterContextGenericArg(UT_KEY(OS_chmod), access_mode);
245245

246246
int32 Status;
247247

0 commit comments

Comments
 (0)