Skip to content

Commit 553cf72

Browse files
authored
Merge pull request #23 from skliper/fix15-apply-style
Fix #15, Apply standard style
2 parents 20f9135 + 3b5bca1 commit 553cf72

File tree

10 files changed

+45
-82
lines changed

10 files changed

+45
-82
lines changed

fsw/public_inc/sample_lib.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
**
2121
** File: sample_lib.h
2222
**
23-
** Purpose:
23+
** Purpose:
2424
** Specification for the sample library functions.
2525
**
2626
*************************************************************************/
@@ -58,21 +58,20 @@
5858
*************************************************************************/
5959
int32 SAMPLE_LibInit(void);
6060

61-
6261
/************************************************************************/
63-
/** \brief Sample Lib Function
64-
**
62+
/** \brief Sample Lib Function
63+
**
6564
** \par Description
6665
** This is a sample function
6766
**
6867
** \par Assumptions, External Events, and Notes:
6968
** None
70-
**
69+
**
7170
** \return Execution status, see \ref CFEReturnCodes
7271
**
73-
**
72+
**
7473
*************************************************************************/
75-
int32 SAMPLE_Function( void );
74+
int32 SAMPLE_Function(void);
7675

7776
#endif /* _sample_lib_h_ */
7877

fsw/src/sample_lib.c

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
**
2121
** File: sample_lib.c
2222
**
23-
** Purpose:
23+
** Purpose:
2424
** Sample CFS library
2525
**
2626
*************************************************************************/
@@ -42,7 +42,7 @@ char SAMPLE_Buffer[SAMPLE_LIB_BUFFER_SIZE];
4242
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
4343
/* */
4444
/* Library Initialization Routine */
45-
/* cFE requires that a library have an initialization routine */
45+
/* cFE requires that a library have an initialization routine */
4646
/* */
4747
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
4848
int32 SAMPLE_LibInit(void)
@@ -57,37 +57,32 @@ int32 SAMPLE_LibInit(void)
5757
* the pointer to the destination buffer, so it should be impossible
5858
* for this to ever fail when linked with a compliant C library.
5959
*/
60-
if (strncpy(SAMPLE_Buffer, "SAMPLE DATA", sizeof(SAMPLE_Buffer)-1) !=
61-
SAMPLE_Buffer)
60+
if (strncpy(SAMPLE_Buffer, "SAMPLE DATA", sizeof(SAMPLE_Buffer) - 1) != SAMPLE_Buffer)
6261
{
6362
return CFE_STATUS_NOT_IMPLEMENTED;
6463
}
65-
64+
6665
/* ensure termination */
67-
SAMPLE_Buffer[sizeof(SAMPLE_Buffer)-1] = 0;
66+
SAMPLE_Buffer[sizeof(SAMPLE_Buffer) - 1] = 0;
6867

68+
OS_printf("SAMPLE Lib Initialized. Version %d.%d.%d.%d\n", SAMPLE_LIB_MAJOR_VERSION, SAMPLE_LIB_MINOR_VERSION,
69+
SAMPLE_LIB_REVISION, SAMPLE_LIB_MISSION_REV);
6970

70-
OS_printf ("SAMPLE Lib Initialized. Version %d.%d.%d.%d\n",
71-
SAMPLE_LIB_MAJOR_VERSION,
72-
SAMPLE_LIB_MINOR_VERSION,
73-
SAMPLE_LIB_REVISION,
74-
SAMPLE_LIB_MISSION_REV);
75-
7671
return CFE_SUCCESS;
77-
78-
}/* End SAMPLE_LibInit */
72+
73+
} /* End SAMPLE_LibInit */
7974

8075
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
8176
/* */
82-
/* Sample Lib function */
77+
/* Sample Lib function */
8378
/* */
8479
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
85-
int32 SAMPLE_Function( void )
80+
int32 SAMPLE_Function(void)
8681
{
87-
OS_printf ("SAMPLE_Function called, buffer=\'%s\'\n", SAMPLE_Buffer);
82+
OS_printf("SAMPLE_Function called, buffer=\'%s\'\n", SAMPLE_Buffer);
83+
84+
return (CFE_SUCCESS);
8885

89-
return(CFE_SUCCESS);
90-
9186
} /* End SAMPLE_Function */
9287

9388
/************************/

fsw/src/sample_lib_internal.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
**
2121
** File: sample_lib_internal.h
2222
**
23-
** Purpose:
23+
** Purpose:
2424
** An example of an internal (private) header file for SAMPLE Lib
2525
**
2626
** Notes:
@@ -36,8 +36,7 @@
3636
** Macro Definitions
3737
*************************************************************************/
3838

39-
#define SAMPLE_LIB_BUFFER_SIZE 16
40-
39+
#define SAMPLE_LIB_BUFFER_SIZE 16
4140

4241
/*************************************************************************
4342
** Internal Data Structures
@@ -53,7 +52,6 @@ extern char SAMPLE_Buffer[SAMPLE_LIB_BUFFER_SIZE];
5352
*/
5453
int32 SAMPLE_LibInit(void);
5554

56-
5755
#endif /* _sample_lib_internal_h_ */
5856

5957
/************************/

fsw/src/sample_lib_version.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@
2929
#ifndef _sample_lib_version_h_
3030
#define _sample_lib_version_h_
3131

32-
33-
#define SAMPLE_LIB_MAJOR_VERSION 1
34-
#define SAMPLE_LIB_MINOR_VERSION 1
35-
#define SAMPLE_LIB_REVISION 3
36-
#define SAMPLE_LIB_MISSION_REV 0
37-
32+
#define SAMPLE_LIB_MAJOR_VERSION 1
33+
#define SAMPLE_LIB_MINOR_VERSION 1
34+
#define SAMPLE_LIB_REVISION 3
35+
#define SAMPLE_LIB_MISSION_REV 0
3836

3937
#endif /* _sample_lib_version_h_ */
4038

unit-test/coveragetest/coveragetest_sample_lib.c

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,12 @@ typedef struct
6161

6262
} SAMPLE_Function_TestState_t;
6363

64-
6564
/*
6665
* A local helper (hook) function for the OS_printf stub provided by OSAL.
6766
* This confirms internal content of the format string and arguments.
6867
*/
69-
static int32 UT_printf_hook(void *UserObj, int32 StubRetcode, uint32 CallCount,
70-
const UT_StubContext_t *Context, va_list va)
68+
static int32 UT_printf_hook(void *UserObj, int32 StubRetcode, uint32 CallCount, const UT_StubContext_t *Context,
69+
va_list va)
7170
{
7271
SAMPLE_Function_TestState_t *State = UserObj;
7372

@@ -77,9 +76,7 @@ static int32 UT_printf_hook(void *UserObj, int32 StubRetcode, uint32 CallCount,
7776
* detail would not be needed, but this serves as an example
7877
* of how it can be done.
7978
*/
80-
if (Context->ArgCount > 0 &&
81-
strcmp(Context->ArgPtr[0],
82-
"SAMPLE_Function called, buffer=\'%s\'\n") == 0)
79+
if (Context->ArgCount > 0 && strcmp(Context->ArgPtr[0], "SAMPLE_Function called, buffer=\'%s\'\n") == 0)
8380
{
8481
State->format_string_valid = true;
8582

@@ -98,8 +95,6 @@ static int32 UT_printf_hook(void *UserObj, int32 StubRetcode, uint32 CallCount,
9895
return 0;
9996
}
10097

101-
102-
10398
/*
10499
**********************************************************************************
105100
** TEST CASE FUNCTIONS
@@ -115,8 +110,7 @@ void Test_SAMPLE_LibInit(void)
115110

116111
/* Set a data buffer for strncpy()
117112
* This overriddes what it would normally do */
118-
UT_SetDataBuffer(UT_KEY(OCS_strncpy), UT_TESTBUFFER,
119-
sizeof (UT_TESTBUFFER), false);
113+
UT_SetDataBuffer(UT_KEY(OCS_strncpy), UT_TESTBUFFER, sizeof(UT_TESTBUFFER), false);
120114

121115
/* nominal case should return SUCCESS */
122116
UT_TEST_FUNCTION_RC(SAMPLE_LibInit(), CFE_SUCCESS);
@@ -132,8 +126,7 @@ void Test_SAMPLE_LibInit(void)
132126
* This requires use of the local accessor routine to get to the
133127
* internal buffer, which is declared "static"
134128
*/
135-
UtAssert_StrCmp(UT_TESTBUFFER, SAMPLE_Buffer,
136-
"Internal buffer content valid");
129+
UtAssert_StrCmp(UT_TESTBUFFER, SAMPLE_Buffer, "Internal buffer content valid");
137130

138131
/* Test failure of the underlying library call */
139132
UT_SetForceFail(UT_KEY(OCS_strncpy), -1);
@@ -170,8 +163,6 @@ void Test_SAMPLE_Function(void)
170163
UtAssert_True(state.printf_content_valid, "OS_printf content test");
171164
}
172165

173-
174-
175166
/*
176167
* Setup function prior to every test
177168
*/
@@ -183,11 +174,7 @@ void Sample_UT_Setup(void)
183174
/*
184175
* Teardown function after every test
185176
*/
186-
void Sample_UT_TearDown(void)
187-
{
188-
189-
}
190-
177+
void Sample_UT_TearDown(void) {}
191178

192179
/*
193180
* Register the test cases to execute with the unit test tool
@@ -197,8 +184,3 @@ void UtTest_Setup(void)
197184
ADD_TEST(SAMPLE_LibInit);
198185
ADD_TEST(SAMPLE_Function);
199186
}
200-
201-
202-
203-
204-

unit-test/coveragetest/sample_lib_coveragetest_common.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,18 @@
4949
* frequent case where a function needs to be called and
5050
* an int32 return code needs to be tested.
5151
*/
52-
#define UT_TEST_FUNCTION_RC(func,exp) \
53-
{ \
54-
int32 rcexp = exp; \
55-
int32 rcact = func; \
56-
UtAssert_True(rcact == rcexp, "%s (%ld) == %s (%ld)", \
57-
#func, (long)rcact, #exp, (long)rcexp); \
58-
}
52+
#define UT_TEST_FUNCTION_RC(func, exp) \
53+
{ \
54+
int32 rcexp = exp; \
55+
int32 rcact = func; \
56+
UtAssert_True(rcact == rcexp, "%s (%ld) == %s (%ld)", #func, (long)rcact, #exp, (long)rcexp); \
57+
}
5958

6059
/*
6160
* Macro to add a test case to the list of tests to execute
6261
* This just simplifies the use of UtTest_Add()
6362
*/
64-
#define ADD_TEST(test) UtTest_Add((Test_ ## test),Sample_UT_Setup,Sample_UT_TearDown, #test)
63+
#define ADD_TEST(test) UtTest_Add((Test_##test), Sample_UT_Setup, Sample_UT_TearDown, #test)
6564

6665
/*
6766
* Setup function prior to every test
@@ -74,4 +73,3 @@ void Sample_UT_Setup(void);
7473
void Sample_UT_TearDown(void);
7574

7675
#endif
77-

unit-test/inc/OCS_string.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
/* prototypes normally declared in string.h */
3838
/* ----------------------------------------- */
3939

40-
extern char *OCS_strncpy (char * dest, const char * src, unsigned long size);
41-
40+
extern char *OCS_strncpy(char *dest, const char *src, unsigned long size);
4241

4342
#endif /* _STUB_STRING_H_ */
44-

unit-test/override_inc/string.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@
3939
/* mappings for declarations in string.h */
4040
/* ----------------------------------------- */
4141

42-
#define strncpy OCS_strncpy
43-
42+
#define strncpy OCS_strncpy
4443

4544
#endif /* _OVERRIDE_STRING_H_ */
46-

unit-test/override_src/libc_string_stubs.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,12 @@
4949
*/
5050
#include <OCS_string.h>
5151

52-
5352
/* **********************************
5453
* Implementation of OCS_strncpy stub
5554
* **********************************/
5655
char *OCS_strncpy(char *dst, const char *src, unsigned long size)
5756
{
58-
int32 Status;
57+
int32 Status;
5958
uint32 CopySize;
6059

6160
Status = UT_DEFAULT_IMPL(OCS_strncpy);
@@ -66,7 +65,7 @@ char *OCS_strncpy(char *dst, const char *src, unsigned long size)
6665
* a "failure" response -
6766
* the real C library would never do this.
6867
*/
69-
return (char*)0;
68+
return (char *)0;
7069
}
7170
/*
7271
* Demonstrate use of a test-provided local data buffer

ut-stubs/sample_lib_stubs.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,14 @@ int32 SAMPLE_LibInit(void)
6464
*/
6565
return UT_DEFAULT_IMPL(SAMPLE_LibInit);
6666

67-
}/* End SAMPLE_LibInit */
67+
} /* End SAMPLE_LibInit */
6868

6969
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
7070
/* */
7171
/* Sample Lib function stub */
7272
/* */
7373
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
74-
int32 SAMPLE_Function( void )
74+
int32 SAMPLE_Function(void)
7575
{
7676
return UT_DEFAULT_IMPL(SAMPLE_Function);
77-
7877
} /* End SAMPLE_Function */
79-

0 commit comments

Comments
 (0)