Adapted to style guidelines

This commit is contained in:
stass 2023-04-27 15:50:37 +03:00
parent cc951fc3be
commit 2b3dd6e133
2 changed files with 8 additions and 8 deletions

View file

@ -159,7 +159,8 @@ static const map_str2str yang_snmp_types[] = {
/* A function that checks that all subtypes of the union are the same /* A function that checks that all subtypes of the union are the same
* @param[in] ytype Yang resolved type (a union in this case) * @param[in] ytype Yang resolved type (a union in this case)
* @param[out] cb Buffer where type of subtypes is written * @param[out] cb Buffer where type of subtypes is written
* @retval 1 - true(All subtypes are the same), 0 - false * @retval 1 - true(All subtypes are the same)
* @retval 0 - false
*/ */
int is_same_subtypes_union(yang_stmt *ytype, cbuf *cb) int is_same_subtypes_union(yang_stmt *ytype, cbuf *cb)
{ {
@ -178,8 +179,7 @@ int is_same_subtypes_union(yang_stmt *ytype, cbuf *cb)
* not resolved types (unless they are built-in, but the resolve call is * not resolved types (unless they are built-in, but the resolve call is
* made in the union_one call. * made in the union_one call.
*/ */
while ((y_sub_type = yn_each(ytype, y_sub_type)) != NULL) while ((y_sub_type = yn_each(ytype, y_sub_type)) != NULL){
{
if (yang_keyword_get(y_sub_type) != Y_TYPE) if (yang_keyword_get(y_sub_type) != Y_TYPE)
continue; continue;
@ -194,8 +194,7 @@ int is_same_subtypes_union(yang_stmt *ytype, cbuf *cb)
else else
break; break;
} }
if( NULL == y_sub_type && NULL != type_str ) if (NULL == y_sub_type && NULL != type_str){
{
cbuf_append_str(cb, resolved_type_str); cbuf_append_str(cb, resolved_type_str);
retval = 1; retval = 1;
} }
@ -204,8 +203,7 @@ int is_same_subtypes_union(yang_stmt *ytype, cbuf *cb)
char* yang_type_to_snmp(yang_stmt *ytype, char* yang_type_str) char* yang_type_to_snmp(yang_stmt *ytype, char* yang_type_str)
{ {
char* type_str = yang_type_str; char* type_str = yang_type_str;
if (yang_type_str && strcmp(yang_type_str, "union") == 0) if (yang_type_str && strcmp(yang_type_str, "union") == 0){
{
cbuf *cb = cbuf_new(); cbuf *cb = cbuf_new();
if (is_same_subtypes_union(ytype, cb) > 0) if (is_same_subtypes_union(ytype, cb) > 0)
type_str = cbuf_get(cb); type_str = cbuf_get(cb);

View file

@ -57,6 +57,7 @@ module clixon-example{
leaf Index{ leaf Index{
type int32; type int32;
smiv2:oid "1.3.6.1.2.1.47.1.1.1.1.1"; smiv2:oid "1.3.6.1.2.1.47.1.1.1.1.1";
smiv2:max-access "read-only";
} }
leaf Union_exm{ leaf Union_exm{
description "Union with same subtypes"; description "Union with same subtypes";
@ -67,6 +68,7 @@ module clixon-example{
type int32; type int32;
} }
smiv2:oid "1.3.6.1.2.1.47.1.1.1.1.2"; smiv2:oid "1.3.6.1.2.1.47.1.1.1.1.2";
smiv2:max-access "read-only";
} }
} }
} }