|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v3 23/25] tools/xenstore: merge is_valid_nodename() into canonicalize()
On 03.08.23 23:46, Julien Grall wrote: Hi, On 24/07/2023 12:02, Juergen Gross wrote:Today is_valid_nodename() is always called directly after calling canonicalize(), with the exception of do_unwatch(), where the call is missing (which is not correct, but results just in a wrong error reason being returned).While this change makes sense...Merge is_valid_nodename() into canonicalize(). While at it merge valid_chars() into it, too.... I am not in favor of folding the code is_valid_nodename() and valid_chars() into canonicalize() because the code is now more difficult to read. Also, the keeping the split would allow to free the 'name' in case of an error without adding too much goto in the code. I don't think we can easily free name in an error case, at that would require to keep knowledge that name was just allocated in the non-canonical case. Signed-off-by: Juergen Gross <jgross@xxxxxxxx> --- V3: - new patch --- tools/xenstore/xenstored_core.c | 89 ++++++++++++++------------------ tools/xenstore/xenstored_core.h | 6 +-- tools/xenstore/xenstored_watch.c | 16 ++---- 3 files changed, 45 insertions(+), 66 deletions(-) diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c index ea5a1a9cce..ec20bc042d 100644 --- a/tools/xenstore/xenstored_core.c +++ b/tools/xenstore/xenstored_core.c@@ -1210,42 +1210,6 @@ void send_ack(struct connection *conn, enum xsd_sockmsg_type type) Really? It is possible, of course, but it is adding more code churn. Remember that "name" is allocated only in case of a relative path, so freeing it needs to be conditional, too (yes, it would be possible via comparing name to node). In case you want me to go this route, I can rearrange the code in order to avoid multiple error exits by having only one large if () testing for all possible violations. + if (!name) + return NULL; + } else + name = (char *)node;Why does name need to be const? I think the question was posed in a wrong way. :-) I'll change name to be const char *. Juergen Attachment:
OpenPGP_0xB0DE9DD628BF132F.asc Attachment:
OpenPGP_signature
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |