[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-tar] two small patches
From: |
Giuseppe Scrivano |
Subject: |
[Bug-tar] two small patches |
Date: |
Tue, 15 Jun 2010 17:53:44 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) |
Hello,
I have attached two small patches.
Cheers,
Giuseppe
>From 7512468a7f9f354839a974d69bd2341deb64e1b4 Mon Sep 17 00:00:00 2001
From: Giuseppe Scrivano <address@hidden>
Date: Tue, 15 Jun 2010 17:04:22 +0200
Subject: [PATCH 1/2] Shutup a gcc warning.
* src/common.h: Add prototype for `label_notfound'.
---
src/common.h | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/src/common.h b/src/common.h
index 3b91f46..5a4e054 100644
--- a/src/common.h
+++ b/src/common.h
@@ -692,6 +692,7 @@ struct name *addname (char const *string, int change_dir,
void remname (struct name *name);
bool name_match (const char *name);
void names_notfound (void);
+void label_notfound (void);
void collect_and_sort_names (void);
struct name *name_scan (const char *name);
struct name const *name_from_list (void);
--
1.7.1
>From 3100005a9a4aec2dce3feb97a46f79dbb7637fe3 Mon Sep 17 00:00:00 2001
From: Giuseppe Scrivano <address@hidden>
Date: Tue, 15 Jun 2010 17:39:00 +0200
Subject: [PATCH 2/2] Remove function that works like `strncpy'.
* src/create.c (tar_copy_str): Remove function.
(tar_name_copy_str): Use `strncpy' instead of `tar_copy_str'.
(string_to_chars): Likewise.
(dump_hard_link): Likewise.
(dump_file0): Likewise.
---
src/create.c | 20 ++++----------------
1 files changed, 4 insertions(+), 16 deletions(-)
diff --git a/src/create.c b/src/create.c
index c69d340..26c89df 100644
--- a/src/create.c
+++ b/src/create.c
@@ -169,25 +169,13 @@ to_octal (uintmax_t value, char *where, size_t size)
while (i);
}
-/* Copy at most LEN bytes from the string SRC to DST. Terminate with
- NUL unless SRC is LEN or more bytes long. */
-
-static void
-tar_copy_str (char *dst, const char *src, size_t len)
-{
- size_t i;
- for (i = 0; i < len; i++)
- if (! (dst[i] = src[i]))
- break;
-}
-
/* Same as tar_copy_str, but always terminate with NUL if using
is OLDGNU format */
static void
tar_name_copy_str (char *dst, const char *src, size_t len)
{
- tar_copy_str (dst, src, len);
+ strncpy (dst, src, len);
if (archive_format == OLDGNU_FORMAT)
dst[len-1] = 0;
}
@@ -475,7 +463,7 @@ uintmax_to_chars (uintmax_t v, char *p, size_t s)
void
string_to_chars (char const *str, char *p, size_t s)
{
- tar_copy_str (p, str, s);
+ strncpy (p, str, s);
p[s - 1] = '\0';
}
@@ -1406,7 +1394,7 @@ dump_hard_link (struct tar_stat_info *st)
blk = start_header (st);
if (!blk)
return false;
- tar_copy_str (blk->header.linkname, link_name, NAME_FIELD_SIZE);
+ strncpy (blk->header.linkname, link_name, NAME_FIELD_SIZE);
blk->header.typeflag = LNKTYPE;
finish_header (st, blk, block_ordinal);
@@ -1707,7 +1695,7 @@ dump_file0 (struct tar_stat_info *st, const char *p,
header = start_header (st);
if (!header)
return;
- tar_copy_str (header->header.linkname, st->link_name, NAME_FIELD_SIZE);
+ strncpy (header->header.linkname, st->link_name, NAME_FIELD_SIZE);
header->header.typeflag = SYMTYPE;
finish_header (st, header, block_ordinal);
/* nothing more to do to it */
--
1.7.1
- [Bug-tar] two small patches,
Giuseppe Scrivano <=