Jinoh Kang (@iamahuman) commented about server/fd.c:
- /* same dentry means a no-op */
- if (!strcmp( srcname, dstname )) goto ret;
- /* This is more complicated now, because in case of a casefold (+F) directory, the destination may very well be the same dentry,
* even if the name doesn't match (if it differs just by case), in which case unlinking it is wrong and can be dangerous. Instead,
* we first rename the source to a temporary filename in the same directory. If this is a casefold dir, this will also remove the
* destination, otherwise the destination still exists. We then create a hardlink from the destination to our temporary name, and
* finally, unlink the temporary. This still works if the directory is case sensitive, so it's not a problem in either case. */
- tmp_value += (current_time >> 16) + current_time;
- for (i = 0; i < 0x8000; i++, tmp_value += 7777)
- {
sprintf( tmpname, tmpname_fmt, tmp_value );
if (fstatat( dirfd, tmpname, &st, 0 )) /* tmpname doesn't exist */
break;
- }
- if (i < 0x8000)
Better flip the condition for readability. Also needs to set error.
```suggestion:-0+0 if (i >= 0x8000) { set_error( STATUS_UNSUCCESSFUL ); goto ret; } ```
...then dedent the following code.