yanglint: Add commands for sample skeleton generation and IETF validation#2531
yanglint: Add commands for sample skeleton generation and IETF validation#2531HanzlikPetr wants to merge 2 commits into
Conversation
Roytak
left a comment
There was a problem hiding this comment.
Mostly smaller things, good overall.
8a82540 to
9cb0f82
Compare
9cb0f82 to
278ef63
Compare
| /** | ||
| * @copydoc cmd_add_opt | ||
| */ | ||
| int cmd_sample_opt(struct yl_opt *yo, const char *cmdline, char ***posv, int *posc); |
There was a problem hiding this comment.
Missing newline after this one.
|
|
||
| /* reset getopt */ | ||
| optind = 0; | ||
| while ((opt = getopt_long(argc, argv, "f:ho:", options, &opt_index)) != -1) { |
There was a problem hiding this comment.
Please keep the order of the chars the same as in options to easily keep track of them.
| } | ||
|
|
||
| static void | ||
| print_xml_nodes(struct ly_out *out, const struct lysc_node *node, int *space_count) |
There was a problem hiding this comment.
Why is space_count an out parameter? It should be simpler to just use an int space_count, no need to decrease the count then. Also, missing doxygen.
| case LY_TYPE_INT64: | ||
| case LY_TYPE_UINT64: | ||
| case LY_TYPE_DEC64: | ||
| return 1; | ||
|
|
||
| default: | ||
| return 1; | ||
| } |
There was a problem hiding this comment.
Based on what were the specific types selected and rest put into default? Best to just enumerate all the types and not use any default.
| return 0; | ||
| } | ||
|
|
||
| if (ly_pattern_compile(NULL, pattern, &pcre2_code) != 0) { |
There was a problem hiding this comment.
Read the docs, but I think you do not have to call ly_pattern_compile() if you do not want to reuse the pattern code, just pass NULL to ly_pattern_match().
| LY_LIST_FOR(data, root) { | ||
| is_mandatory = 0; | ||
|
|
||
| if (root->flags & LYS_MAND_TRUE) { |
There was a problem hiding this comment.
This check is enough, the other ones are covered by this, the flag is set for those other cases as well.
| * @param node_name The string name of the parent node to provide context in the error message. | ||
| * @param found_2119 A pointer to an integer flag that tracks if RFC 2119 keywords are used in the module/submodule. | ||
| */ | ||
| #define CHECK_INNER_DEFS(node_ptr, node_type_str, node_name, found_2119) \ |
There was a problem hiding this comment.
Please refactor to a function, macro too complex.
| * @return 0 on successful execution of the validation pipeline (note: this returns 0 even if IETF compliance warnings/errors were printed to the output). | ||
| * @return 1 on fatal execution errors (e.g., module not found, module failed to compile, or memory allocation failure). | ||
| */ | ||
| int ietf(struct ly_ctx **ctx, struct yl_opt *yo, const char *posv); |
There was a problem hiding this comment.
Please use clear names with the local prefix even for function in the internal API. yanglint uses yl prefix, so yl_validate_ietf, for example.
| {"json-null", no_argument, NULL, 'J'}, | ||
| {"debug", required_argument, NULL, 'G'}, | ||
| {"sample-skeleton", required_argument, NULL, 'S'}, | ||
| {"ietf", no_argument, NULL, 1000}, |
There was a problem hiding this comment.
Please always use a valid single-char variant for every command.
No description provided.