Thread (101 messages) flat view 101 messages, 9 authors, 2021-11-02

Re: [PATCH v2 04/14] dir: select directories correctly

From: Derrick Stolee <hidden>
Date: 2021-09-15 16:43:12

On 9/15/2021 10:54 AM, Elijah Newren wrote:
quoted
+       /*
+        * Use 'alloc' as an indicator that the string has not been
+        * initialized, in case the parent is the root directory.
+        */
+       if (!path_parent->alloc) {
+               char *slash;
+               strbuf_addstr(path_parent, pathname);
+               slash = find_last_dir_sep(path_parent->buf);
+
+               if (slash)
+                       *slash = '\0';
Are you breaking strbuf invariants here?  path_parent->len will not be
corrected by this string manipulation.  Perhaps replace this if-else
block with

    strbuf_setlen(path_parent, slash ? slash - path_parent->buf : 0)
Yes, I am. I noticed and fixed this when I was rewriting this
patch for Ævar's feedback. Thanks for pointing it out.

Thanks,
-Stolee
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help