+2020-12-06 Bruno Haible <bruno@clisp.org>
+
+ backupfile: Use idx_t for nonnegative ptrdiff_t variables.
+ * lib/backupfile.c: Include idx.h.
+ (numbered_backup): Mark base_offset as nonnegative.
+ (backupfile_internal): Likewise.
+ * modules/backup-rename (Depends-on): Add idx.
+ * modules/backupfile (Depends-on): Likewise.
+
2020-12-05 Paul Eggert <eggert@cs.ucla.edu>
doc: fix curved quotes issue
#include "backup-internal.h"
-#include "attribute.h"
-#include "basename-lgpl.h"
-#include "opendirat.h"
-#include "renameatu.h"
-#include "xalloc-oversized.h"
-
#include <errno.h>
#include <fcntl.h>
#include <stdbool.h>
#include <string.h>
#include <unistd.h>
+#include "attribute.h"
+#include "basename-lgpl.h"
+#include "idx.h"
+#include "opendirat.h"
+#include "renameatu.h"
+#include "xalloc-oversized.h"
+
#ifndef _D_EXACT_NAMLEN
# define _D_EXACT_NAMLEN(dp) strlen ((dp)->d_name)
#endif
static enum numbered_backup_result
numbered_backup (int dir_fd, char **buffer, size_t buffer_size, size_t filelen,
- ptrdiff_t base_offset, DIR **dirpp, int *pnew_fd)
+ idx_t base_offset, DIR **dirpp, int *pnew_fd)
{
enum numbered_backup_result result = BACKUP_IS_NEW;
DIR *dirp = *dirpp;
backupfile_internal (int dir_fd, char const *file,
enum backup_type backup_type, bool rename)
{
- ptrdiff_t base_offset = last_component (file) - file;
+ idx_t base_offset = last_component (file) - file;
size_t filelen = base_offset + strlen (file + base_offset);
if (! simple_backup_suffix)