Skip to content

Commit 8dd2dd1

Browse files
refactor: Zephyr codestyle alignment (onomondo#89)
1 parent 4a96889 commit 8dd2dd1

File tree

20 files changed

+1585
-1338
lines changed

20 files changed

+1585
-1338
lines changed

.editorconfig

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Copied from Zephyr: https://github.com/zephyrproject-rtos/zephyr/blob/main/.editorconfig
2+
3+
# EditorConfig: https://editorconfig.org/
4+
15
# top-most EditorConfig file
26
root = true
37

@@ -7,6 +11,7 @@ charset = utf-8
711
end_of_line = lf
812
insert_final_newline = true
913
trim_trailing_whitespace = true
14+
max_line_length = 100
1015

1116
# Assembly
1217
[*.S]
@@ -23,12 +28,67 @@ indent_size = 8
2328
indent_style = tab
2429
indent_size = 8
2530

31+
# Linker Script
32+
[*.ld]
33+
indent_style = tab
34+
indent_size = 8
35+
36+
# Python
37+
[*.py]
38+
indent_style = space
39+
indent_size = 4
40+
41+
# Perl
42+
[*.pl]
43+
indent_style = tab
44+
indent_size = 8
45+
46+
# reStructuredText
47+
[*.rst]
48+
indent_style = space
49+
indent_size = 3
50+
2651
# YAML
2752
[*.{yml,yaml}]
2853
indent_style = space
2954
indent_size = 2
3055

56+
# Shell Script
57+
[*.sh]
58+
indent_style = space
59+
indent_size = 4
60+
61+
# Windows Command Script
62+
[*.cmd]
63+
end_of_line = crlf
64+
indent_style = tab
65+
indent_size = 8
66+
67+
# Valgrind Suppression File
68+
[*.supp]
69+
indent_style = space
70+
indent_size = 3
71+
3172
# CMake
3273
[{CMakeLists.txt,*.cmake}]
3374
indent_style = space
3475
indent_size = 2
76+
77+
# Makefile
78+
[Makefile]
79+
indent_style = tab
80+
indent_size = 8
81+
82+
# Device tree
83+
[*.{dts,dtsi,overlay}]
84+
indent_style = tab
85+
indent_size = 8
86+
87+
# Git commit messages
88+
[COMMIT_EDITMSG]
89+
max_line_length = 75
90+
91+
# Kconfig
92+
[Kconfig*]
93+
indent_style = tab
94+
indent_size = 8

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ lib/onomondo
6262
!lib/libuicc.a
6363
!lib/libstorage.a
6464

65+
.*project
66+
.settings
67+
.envrc
6568
.vscode
6669
*debug*
6770
.DS_Store

lib/build_asserts.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@
55
#define EXPECTED_MIN_HEAP_SIZE 30000
66

77
BUILD_ASSERT(CONFIG_HEAP_MEM_POOL_SIZE >= EXPECTED_MIN_HEAP_SIZE,
8-
"SoftSIM: "
9-
"Heap memory pool size is not valid. "
10-
"Please reconfigure the project.");
8+
"SoftSIM: "
9+
"Heap memory pool size is not valid. "
10+
"Please reconfigure the project.");
1111

1212
/* In NCS, when NVS backend for Settings is chosen, `nvs_partition` partition is not included by
1313
* the Partition Manager.
14-
* `nvs_storage`partition is required by SoftSIM. FCB backend for Settings should be used instead
14+
* `nvs_storage` partition is required by SoftSIM. FCB backend for Settings should be used instead
1515
* of NVS backend.
1616
*/
1717
#if CONFIG_SETTINGS_NVS
18-
BUILD_ASSERT(0, "Softsim: Please disable CONFIG_SETTINGS_NVS. Choose CONFIG_SETTINGS_FCB instead.");
18+
BUILD_ASSERT(0, "SoftSIM: Please disable CONFIG_SETTINGS_NVS. Choose CONFIG_SETTINGS_FCB instead.");
1919
#else
2020
BUILD_ASSERT(CONFIG_PM_PARTITION_SIZE_NVS_STORAGE == EXPECTED_PARTITION_SIZE,
21-
"SoftSIM: "
22-
"nvs_partition size is not valid. "
23-
"Please reconfigure the project.");
21+
"SoftSIM: "
22+
"nvs_partition size is not valid. "
23+
"Please reconfigure the project.");
2424
#endif

lib/include/nrf_softsim.h

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,37 @@
1-
#ifndef _NRF_SOFTSIM_H_
2-
#define _NRF_SOFTSIM_H_
1+
#ifndef _NRF_SOFTSIM_H
2+
#define _NRF_SOFTSIM_H
3+
34
#include <stddef.h>
5+
#include <stdint.h>
46

57
/**
6-
* @brief Initialize the SoftSIM library and install handlers. Only use if
7-
* CONFIG_NRF_SOFTSIM_AUTO_INIT is not set.
8+
* @brief Initialize the SoftSIM library and install handlers
89
*
10+
* Only use if CONFIG_NRF_SOFTSIM_AUTO_INIT is not set.
11+
*
12+
* This function initializes the SoftSIM module by calling the Onomondo
13+
* initialization function. It sets up the necessary context and prepares
14+
* the SoftSIM for use.
915
*
1016
* @return 0 on success
1117
*/
1218
int nrf_softsim_init(void);
1319

1420
/**
15-
* @brief
16-
*
17-
* Provision a SoftSIM profile to protected storage.
18-
* len must be exactly 328 bytes long.
21+
* @brief Provision a SoftSIM profile to protected storage
1922
*
23+
* @param profile String representing a SoftSIM profile. This encodes IMSI, ICCID, and necessary keys
24+
* @param len Length of the profile passed
2025
*
21-
* @param profile String representing a SoftSIM profile. This encodes IMSI,
22-
* ICCID and necessary keys.
23-
* @param len Length of profile passed
2426
* @return 0 on success
2527
*/
2628
int nrf_softsim_provision(uint8_t *profile, size_t len);
2729

2830
/**
2931
* @brief Check if a SoftSIM profile is provisioned in protected storage.
3032
*
31-
*
3233
* @return 1 if provisioned, 0 if not
3334
*/
3435
int nrf_softsim_check_provisioned(void);
3536

36-
#endif /* _NRF_SOFTSIM_H_ */
37+
#endif /* _NRF_SOFTSIM_H */

lib/include/onomondo/softsim/fs_port.h

Lines changed: 71 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,76 @@
55

66
typedef void *port_FILE;
77

8-
size_t port_fread(void *ptr, size_t size, size_t nmemb, port_FILE fp);
9-
char *port_fgets(char *str, int n, port_FILE fp);
10-
int port_fclose(port_FILE);
11-
port_FILE port_fopen(char *path, char *mode);
12-
int port_fseek(port_FILE fp, long offset, int whence);
13-
long port_ftell(port_FILE fp);
14-
int port_fputc(int c, port_FILE);
15-
int port_access(const char *path, int amode);
16-
size_t port_fwrite(const void *prt, size_t size, size_t count, port_FILE f);
17-
int port_mkdir(const char *, int);
18-
int port_remove(const char *);
19-
int port_rmdir(const char *);
20-
int ss_init_fs();
21-
int ss_deinit_fs();
8+
char *port_fgets(char *str, int n, port_FILE fp);
9+
int port_fclose(port_FILE fp);
10+
int port_fseek(port_FILE fp, long offset, int whence);
11+
long port_ftell(port_FILE fp);
12+
int port_fputc(int c, port_FILE fp);
13+
int port_access(const char *path, int amode);
14+
size_t port_fwrite(const void *ptr, size_t size, size_t count, port_FILE fp);
15+
int port_remove(const char *path);
16+
17+
/**
18+
* @brief Creates a "directory" specified by the given path
19+
*
20+
* @param path The full path to the "directory" to be created
21+
* @param mode The mode in which the directory should be created (currently ignored)
22+
*
23+
* @return 0 on success
24+
*
25+
* @note This function is currently not implemented and always returns 0.
26+
*/
27+
int port_mkdir(const char *path, int mode); /* TODO: Evaluate if this is needed */
28+
29+
/**
30+
* @brief Removes a "directory" specified by the given path
31+
*
32+
* @param path The full path to the "directory" to be removed
33+
*
34+
* @return 0 on success
35+
*
36+
* @note This function is currently not implemented and always returns 0.
37+
*/
38+
int port_rmdir(const char *path); /* TODO: Evaluate if this is needed */
39+
40+
/**
41+
* @brief Provides an implementation of the standard C fopen function
42+
*
43+
* This function opens a file specified by the given path and returns a pointer
44+
* to a file-like object. The mode parameter is currently ignored.
45+
*
46+
* @param path The full path to the file to be opened
47+
* @param mode The mode in which the file should be opened (currently ignored)
48+
*
49+
* @return A pointer to a "file" represented internally by a struct cache_entry,
50+
* or NULL if the operation fails
51+
*/
52+
port_FILE port_fopen(char *path, char *mode);
53+
54+
/**
55+
* @brief Reads data from the given file into the specified memory buffer
56+
*
57+
* This function provides a custom implementation of the standard C fread,
58+
* utilizing an internal cache for optimized performance.
59+
*
60+
* @param ptr Pointer to the destination memory buffer where the data will be stored
61+
* @param size Size of each element to be read, in bytes
62+
* @param nmemb Number of elements to be read
63+
* @param fp Pointer to the file from which data is to be read
64+
*
65+
* @return The total number of elements successfully read, which may be less than
66+
* nmemb if an error occurs or the end of the file is reached
67+
*/
68+
size_t port_fread(void *ptr, size_t size, size_t nmemb, port_FILE fp);
69+
70+
/**
71+
* @brief Initialize SoftSIM filesystem
72+
*/
73+
int ss_init_fs(void);
74+
75+
/**
76+
* @brief Deinitialize SoftSIM filesystem
77+
*/
78+
int ss_deinit_fs(void);
2279

2380
#endif /* FS_PORT_H */

0 commit comments

Comments
 (0)