Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

Commit

Permalink
Wrap ino_hash and dev_hash for libtar_hash_new to match function type
Browse files Browse the repository at this point in the history
Fixes the following gcc 8 warnings:

append.c: In function ‘tar_append_file’:
append.c:109:35: warning: cast between incompatible function types from ‘int (*)(ino_t *)’ {aka ‘int (*)(long unsigned int *)’} to ‘unsigned int (*)(void *, unsigned int)’ [-Wcast-function-type]
   td->td_h = libtar_hash_new(256, (libtar_hashfunc_t)ino_hash);
                                   ^
handle.c: In function ‘tar_init’:
handle.c:52:33: warning: cast between incompatible function types from ‘int (*)(dev_t *)’ {aka ‘int (*)(long unsigned int *)’} to ‘unsigned int (*)(void *, unsigned int)’ [-Wcast-function-type]
   (*t)->h = libtar_hash_new(16, (libtar_hashfunc_t)dev_hash);

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
  • Loading branch information
tklauser committed Apr 3, 2019
1 parent 9c2e044 commit 6379b5d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/append.c
Expand Up @@ -53,6 +53,11 @@ tar_dev_free(tar_dev_t *tdp)
free(tdp);
}

static unsigned int ino_hash_wrap(void *p, unsigned int n)
{
(void)n;
return (unsigned int)ino_hash(p);
}

/* appends a file to the tar archive */
int
Expand Down Expand Up @@ -110,7 +115,7 @@ tar_append_file(TAR *t, const char *realname, const char *savename)
if (td == NULL)
return -1;
td->td_dev = s.st_dev;
td->td_h = libtar_hash_new(256, (libtar_hashfunc_t)ino_hash);
td->td_h = libtar_hash_new(256, ino_hash_wrap);
if (td->td_h == NULL) {
free(td);
return -1;
Expand Down
7 changes: 6 additions & 1 deletion lib/handle.c
Expand Up @@ -29,6 +29,11 @@ const char libtar_version[] = PACKAGE_VERSION;

static tartype_t default_type = { open, close, read, write };

static unsigned int dev_hash_wrap(void *p, unsigned int n)
{
(void)n;
return (unsigned int)dev_hash(p);
}

static int
tar_init(TAR **t, const char *pathname, tartype_t *type,
Expand All @@ -53,7 +58,7 @@ tar_init(TAR **t, const char *pathname, tartype_t *type,
(*t)->h = libtar_hash_new(256,
(libtar_hashfunc_t)path_hashfunc);
else
(*t)->h = libtar_hash_new(16, (libtar_hashfunc_t)dev_hash);
(*t)->h = libtar_hash_new(16, dev_hash_wrap);
if ((*t)->h == NULL)
{
free(*t);
Expand Down

0 comments on commit 6379b5d

Please sign in to comment.