)]}'
{"/PATCHSET_LEVEL":[{"author":{"_account_id":1000021,"name":"Antonio Borneo","email":"borneo.antonio@gmail.com","username":"borneoa"},"change_message_id":"ae6c9cc848752bb3a979560cbda17a0857aa8b44","unresolved":true,"context_lines":[],"source_content_type":"","patch_set":4,"id":"47ed275c_a2caf626","updated":"2025-04-06 09:46:04.000000000","message":"Evgeniy,\nI\u0027m proposing a rewrite of most of the file `target.c`, dropping Jim API.\nWhile it would make obsolete this patch, it could be nice to have the result of your tests run on top of the series https://review.openocd.org/c/openocd/+/8830","commit_id":"0dce5aaf7409031f9de4947030423da687f7100e"},{"author":{"_account_id":1002047,"name":"Evgeniy Naydanov","email":"eugnay@gmail.com","username":"en-sc"},"change_message_id":"1756d22e7f18b7b884c0a7a6486adbc320303a5e","unresolved":true,"context_lines":[],"source_content_type":"","patch_set":4,"id":"40d2934a_e060fc50","in_reply_to":"47ed275c_a2caf626","updated":"2025-04-28 17:37:25.000000000","message":"Antonio,\nSorry for taking so long to reply.\n\nI\u0027ve rebased the tests on top of your patch. The tests themselves have required only minor adjustments.\nHowever, I have also changed the code a bit, please take a look:\nhttps://review.openocd.org/c/openocd/+/8860\nhttps://review.openocd.org/c/openocd/+/8861","commit_id":"0dce5aaf7409031f9de4947030423da687f7100e"}],"src/helper/jim-nvp.c":[{"author":{"_account_id":1001667,"name":"Jan Matyas","email":"jan.matyas@codasip.com","username":"JanMatCodasip"},"change_message_id":"7d6263a03f77e69461e9173ce11b38ae77b8fb57","unresolved":true,"context_lines":[{"line_number":259,"context_line":"\t\tjim_set_result_nvp_unknown(goi-\u003einterp, NULL, goi-\u003eargv[-1], nvptable);"},{"line_number":260,"context_line":"}"},{"line_number":261,"context_line":""},{"line_number":262,"context_line":"void jim_getopt_wrong_num_args(const struct jim_getopt_info *goi, int argc, const char *msg)"},{"line_number":263,"context_line":"{"},{"line_number":264,"context_line":"\tassert(argc \u003e 0 \u0026\u0026 \"Expecting a positive number of context arguments.\");"},{"line_number":265,"context_line":"\tJim_WrongNumArgs(goi-\u003einterp, argc, goi-\u003eargv - argc, msg);"}],"source_content_type":"text/x-csrc","patch_set":2,"id":"d320f7b2_5639ae51","line":262,"updated":"2024-12-12 12:51:35.000000000","message":"Detail: I\u0027d recommend to use the same parameter names as in the .h file:\n\n```\nvoid jim_getopt_wrong_num_args(const struct jim_getopt_info *goi, int cntxt_args,\n\t\tconst char *expctd_args)\n```","commit_id":"dfec79bae99913e16b072b531c85e3c27256d93e"},{"author":{"_account_id":1002047,"name":"Evgeniy Naydanov","email":"eugnay@gmail.com","username":"en-sc"},"change_message_id":"43e2339bcd9330d245f2f417bffd0b5e90c17ae4","unresolved":true,"context_lines":[{"line_number":259,"context_line":"\t\tjim_set_result_nvp_unknown(goi-\u003einterp, NULL, goi-\u003eargv[-1], nvptable);"},{"line_number":260,"context_line":"}"},{"line_number":261,"context_line":""},{"line_number":262,"context_line":"void jim_getopt_wrong_num_args(const struct jim_getopt_info *goi, int argc, const char *msg)"},{"line_number":263,"context_line":"{"},{"line_number":264,"context_line":"\tassert(argc \u003e 0 \u0026\u0026 \"Expecting a positive number of context arguments.\");"},{"line_number":265,"context_line":"\tJim_WrongNumArgs(goi-\u003einterp, argc, goi-\u003eargv - argc, msg);"}],"source_content_type":"text/x-csrc","patch_set":2,"id":"b99cb816_c7394796","line":262,"in_reply_to":"d320f7b2_5639ae51","updated":"2024-12-15 13:16:05.000000000","message":"Addressed.","commit_id":"dfec79bae99913e16b072b531c85e3c27256d93e"}],"src/helper/jim-nvp.h":[{"author":{"_account_id":1001667,"name":"Jan Matyas","email":"jan.matyas@codasip.com","username":"JanMatCodasip"},"change_message_id":"7d6263a03f77e69461e9173ce11b38ae77b8fb57","unresolved":true,"context_lines":[{"line_number":292,"context_line":" */"},{"line_number":293,"context_line":"void jim_getopt_nvp_unknown(struct jim_getopt_info *goi, const struct jim_nvp *lookup, int hadprefix);"},{"line_number":294,"context_line":""},{"line_number":295,"context_line":"/** Create an appropriate error message when there are missing arguments."},{"line_number":296,"context_line":" *"},{"line_number":297,"context_line":" * \\param goi - options info"},{"line_number":298,"context_line":" * \\param cntxt_args - number of arguments to prepend to the message"}],"source_content_type":"text/x-csrc","patch_set":2,"id":"b2add040_014ac3e4","line":295,"updated":"2024-12-12 12:51:35.000000000","message":"If you like:\n\n\"missing arguments\" --\u003e \"missing or excessive\"","commit_id":"dfec79bae99913e16b072b531c85e3c27256d93e"},{"author":{"_account_id":1002047,"name":"Evgeniy Naydanov","email":"eugnay@gmail.com","username":"en-sc"},"change_message_id":"43e2339bcd9330d245f2f417bffd0b5e90c17ae4","unresolved":true,"context_lines":[{"line_number":292,"context_line":" */"},{"line_number":293,"context_line":"void jim_getopt_nvp_unknown(struct jim_getopt_info *goi, const struct jim_nvp *lookup, int hadprefix);"},{"line_number":294,"context_line":""},{"line_number":295,"context_line":"/** Create an appropriate error message when there are missing arguments."},{"line_number":296,"context_line":" *"},{"line_number":297,"context_line":" * \\param goi - options info"},{"line_number":298,"context_line":" * \\param cntxt_args - number of arguments to prepend to the message"}],"source_content_type":"text/x-csrc","patch_set":2,"id":"999d0d7c_5ae5be4e","line":295,"in_reply_to":"b2add040_014ac3e4","updated":"2024-12-15 13:16:05.000000000","message":"Addressed.","commit_id":"dfec79bae99913e16b072b531c85e3c27256d93e"}],"src/rtos/rtos.c":[{"author":{"_account_id":1001667,"name":"Jan Matyas","email":"jan.matyas@codasip.com","username":"JanMatCodasip"},"change_message_id":"7d6263a03f77e69461e9173ce11b38ae77b8fb57","unresolved":true,"context_lines":[{"line_number":117,"context_line":"\tos_free(target);"},{"line_number":118,"context_line":""},{"line_number":119,"context_line":"\tif (goi-\u003eargc \u003d\u003d 0) {"},{"line_number":120,"context_line":"\t\tjim_getopt_wrong_num_args(goi, /*cntxt_args*/ 1,"},{"line_number":121,"context_line":"\t\t\t\t\"?name? ...\");"},{"line_number":122,"context_line":"\t\treturn JIM_ERR;"},{"line_number":123,"context_line":"\t}"}],"source_content_type":"text/x-csrc","patch_set":2,"id":"7b106d8d_8f9339f8","line":120,"updated":"2024-12-12 12:51:35.000000000","message":"Why do we pass cntxt_args\u003d\u003d1 when argc\u003d\u003d0, please? (There are more such occurrences.)\n\nAs a code reader, I find it unusual and counter-intuitive.\n\nCould the edge case cntxt_args\u003d\u003d0 be handled directly inside jim_getopt_wrong_num_args(), perhaps with an explanatory comment?","commit_id":"dfec79bae99913e16b072b531c85e3c27256d93e"},{"author":{"_account_id":1002047,"name":"Evgeniy Naydanov","email":"eugnay@gmail.com","username":"en-sc"},"change_message_id":"43e2339bcd9330d245f2f417bffd0b5e90c17ae4","unresolved":true,"context_lines":[{"line_number":117,"context_line":"\tos_free(target);"},{"line_number":118,"context_line":""},{"line_number":119,"context_line":"\tif (goi-\u003eargc \u003d\u003d 0) {"},{"line_number":120,"context_line":"\t\tjim_getopt_wrong_num_args(goi, /*cntxt_args*/ 1,"},{"line_number":121,"context_line":"\t\t\t\t\"?name? ...\");"},{"line_number":122,"context_line":"\t\treturn JIM_ERR;"},{"line_number":123,"context_line":"\t}"}],"source_content_type":"text/x-csrc","patch_set":2,"id":"4b950bab_cc19e138","line":120,"in_reply_to":"7b106d8d_8f9339f8","updated":"2024-12-15 13:16:05.000000000","message":"The thing is, when an argument is consumed (e.g. by `jim_getopt_nvp()`) `goi-\u003eargc` is decremented and `goi-\u003eargv` is incremented). So `goi-\u003eargc` is not really related to the value of `cntxt_args` at the point of a call, it\u0027s more related to the number of arguments in `expctd_args`.\n`cntxt_args` is the number of *already consumed* arguments to include in the error message.\n\nE.g.:\n\nThe user have passed `target configure -event examine-start` (forgetting to pass the body of the event handler).\nThe corresponding error message would be generated by the call at\nhttps://review.openocd.org/c/openocd/+/8643/2/src/target/target.c#4985:\n```\nif (goi-\u003eargc \u003d\u003d 0) {\n\tjim_getopt_wrong_num_args(goi, /*cntxt_args*/ 2,\n\t\t\"?EVENT-BODY?\");\n\treturn JIM_ERR;\n}\n```\nHere there are 2 context arguments (which option and which event), resulting in:\n```\nwrong # args: should be \"-event examine-start ?EVENT-BODY?\"\n```\nProviding the user with enough context to better identify the point of the error.","commit_id":"dfec79bae99913e16b072b531c85e3c27256d93e"}]}
