@@ -2776,8 +2776,6 @@ Compliant example::
2776
2776
if (condition) { do_a();} else {do_b();}
2777
2777
2778
2778
2779
-
2780
-
2781
2779
CS-03: Tabs shall be used for code indentation
2782
2780
==============================================
2783
2781
@@ -2810,8 +2808,6 @@ A tab character shall be considered 8-character wide when limiting the line
2810
2808
width.
2811
2809
2812
2810
2813
-
2814
-
2815
2811
CS-05: Trailing whitespace shall not be allowed at the end of lines
2816
2812
===================================================================
2817
2813
@@ -2984,8 +2980,6 @@ Compliant example::
2984
2980
}
2985
2981
2986
2982
2987
-
2988
-
2989
2983
CS-13: Braces after if/switch/for/do/while shall be in the same line
2990
2984
====================================================================
2991
2985
@@ -3035,8 +3029,6 @@ Compliant example::
3035
3029
}
3036
3030
3037
3031
3038
-
3039
-
3040
3032
CS-15: A 'switch' statement and its subordinate 'case' shall be aligned
3041
3033
=======================================================================
3042
3034
@@ -3092,8 +3084,6 @@ Compliant example::
3092
3084
param_3);
3093
3085
3094
3086
3095
-
3096
-
3097
3087
CS-17: '//' shall not be used for single-line comments
3098
3088
=======================================================
3099
3089
@@ -3110,3 +3100,158 @@ Compliant example::
3110
3100
// This is a comment
3111
3101
3112
3102
3103
+ Naming Convention
3104
+ *****************
3105
+
3106
+
3107
+ NC-01: Object-like MACRO shall be named with full upper case
3108
+ ============================================================
3109
+
3110
+ Compliant example::
3111
+
3112
+ #define MAX_CONFIG_NAME_SIZE 32U
3113
+
3114
+ .. rst-class :: non-compliant-code
3115
+
3116
+ Non-compliant example::
3117
+
3118
+ #define max_config_name_size 32U
3119
+
3120
+
3121
+ NC-02: Mixed-use of lower case and upper case in function-like MACRO shall not be allowed
3122
+ =========================================================================================
3123
+
3124
+ Function-like MACRO shall be named with either full lower case or full upper
3125
+ case. Mixed-use of lower case and upper case shall not be allowed.
3126
+
3127
+ Compliant example::
3128
+
3129
+ #define max(x, y) ((x) < (y)) ? (y) : (x)
3130
+
3131
+ .. rst-class :: non-compliant-code
3132
+
3133
+ Non-compliant example::
3134
+
3135
+ #define Max(x, y) ((x) < (y)) ? (y) : (x)
3136
+
3137
+
3138
+ NC-03: Data structures exposed to external components shall be named with prefix 'acrn'
3139
+ =======================================================================================
3140
+
3141
+ The data structure types include struct, union, and enum.
3142
+ This rule applies to the data structure with all the following properties:
3143
+
3144
+ a) The data structure is used by multiple modules;
3145
+ b) The corresponding resource is exposed to external components, such as SOS or
3146
+ UOS;
3147
+ c) The name meaning is simplistic or common, such as vcpu or vm.
3148
+
3149
+ Compliant example::
3150
+
3151
+ struct acrn_vcpu {
3152
+ ...
3153
+ };
3154
+
3155
+ .. rst-class :: non-compliant-code
3156
+
3157
+ Non-compliant example::
3158
+
3159
+ struct vcpu {
3160
+ ...
3161
+ };
3162
+
3163
+
3164
+ NC-04: Data structures only used by hypervisor shall be named with prefix 'hv'
3165
+ ==============================================================================
3166
+
3167
+ The data structure types include struct, union, and enum.
3168
+ This rule applies to the data structure with all the following properties:
3169
+
3170
+ a) The data structure is used by multiple modules;
3171
+ b) The corresponding resource is only used by hypervisor;
3172
+ c) The name meaning is simplistic or common, such as timer.
3173
+
3174
+ Compliant example::
3175
+
3176
+ struct hv_timer {
3177
+ ...
3178
+ };
3179
+
3180
+ .. rst-class :: non-compliant-code
3181
+
3182
+ Non-compliant example::
3183
+
3184
+ struct timer {
3185
+ ...
3186
+ };
3187
+
3188
+
3189
+ NC-05: Data structures only used by one module shall be named with the module name as prefix
3190
+ ============================================================================================
3191
+
3192
+ The data structure types include struct, union, and enum.
3193
+ This rule applies to the data structure with all the following properties:
3194
+
3195
+ a) The data structure is only used by one module;
3196
+ b) The name meaning is simplistic or common, such as context.
3197
+
3198
+ Compliant example::
3199
+
3200
+ struct instr_emul_ctxt {
3201
+ ...
3202
+ };
3203
+
3204
+ .. rst-class :: non-compliant-code
3205
+
3206
+ Non-compliant example::
3207
+
3208
+ struct ctxt {
3209
+ ...
3210
+ };
3211
+
3212
+
3213
+ NC-06: Data structures related to hardware resource shall be named with the resource name as suffix
3214
+ ===================================================================================================
3215
+
3216
+ The data structure types include struct, union, and enum.
3217
+ For example:
3218
+
3219
+ a) The data structure related to register shall be named with suffix 'reg';
3220
+ b) The data structure related to segment selector shall be named with suffix
3221
+ 'sel'.
3222
+
3223
+ Compliant example::
3224
+
3225
+ struct lapic_reg {
3226
+ ...
3227
+ };
3228
+
3229
+ .. rst-class :: non-compliant-code
3230
+
3231
+ Non-compliant example::
3232
+
3233
+ struct lapic {
3234
+ ...
3235
+ };
3236
+
3237
+
3238
+ NC-07: Function pointer shall be named with suffix 'fn'
3239
+ =======================================================
3240
+
3241
+ Compliant example::
3242
+
3243
+ struct firmware_operations firmware_sbl_ops = {
3244
+ .init = sbl_init_fn,
3245
+ .get_rsdp = sbl_get_rsdp_fn,
3246
+ };
3247
+
3248
+ .. rst-class :: non-compliant-code
3249
+
3250
+ Non-compliant example::
3251
+
3252
+ struct firmware_operations firmware_sbl_ops = {
3253
+ .init = sbl_init,
3254
+ .get_rsdp = sbl_get_rsdp,
3255
+ };
3256
+
3257
+
0 commit comments