svn commit: r349708 - stable/12/contrib/elftoolchain/libelftc
Mark Johnston
markj at FreeBSD.org
Wed Jul 3 20:54:38 UTC 2019
Author: markj
Date: Wed Jul 3 20:54:36 2019
New Revision: 349708
URL: https://svnweb.freebsd.org/changeset/base/349708
Log:
MFC r349421:
libelftc: Consistently use size_t for string table offsets and sizes.
Modified:
stable/12/contrib/elftoolchain/libelftc/elftc_string_table.c
stable/12/contrib/elftoolchain/libelftc/elftc_string_table_create.3
stable/12/contrib/elftoolchain/libelftc/libelftc.h
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/contrib/elftoolchain/libelftc/elftc_string_table.c
==============================================================================
--- stable/12/contrib/elftoolchain/libelftc/elftc_string_table.c Wed Jul 3 20:53:05 2019 (r349707)
+++ stable/12/contrib/elftoolchain/libelftc/elftc_string_table.c Wed Jul 3 20:54:36 2019 (r349708)
@@ -44,7 +44,7 @@ ELFTC_VCSID("$Id: elftc_string_table.c 2869 2013-01-06
#define ELFTC_STRING_TABLE_POOL_SIZE_INCREMENT (4*1024)
struct _Elftc_String_Table_Entry {
- int ste_idx;
+ ssize_t ste_idx;
SLIST_ENTRY(_Elftc_String_Table_Entry) ste_next;
};
@@ -64,9 +64,9 @@ struct _Elftc_String_Table_Entry {
} while (0)
struct _Elftc_String_Table {
- unsigned int st_len; /* length and flags */
+ size_t st_len; /* length and flags */
int st_nbuckets;
- int st_string_pool_size;
+ size_t st_string_pool_size;
char *st_string_pool;
SLIST_HEAD(_Elftc_String_Table_Bucket,
_Elftc_String_Table_Entry) st_buckets[];
@@ -86,7 +86,7 @@ elftc_string_table_find_hash_entry(Elftc_String_Table
*rhashindex = hashindex;
SLIST_FOREACH(ste, &st->st_buckets[hashindex], ste_next) {
- s = st->st_string_pool + abs(ste->ste_idx);
+ s = st->st_string_pool + labs(ste->ste_idx);
assert(s > st->st_string_pool &&
s < st->st_string_pool + st->st_string_pool_size);
@@ -102,7 +102,7 @@ static int
elftc_string_table_add_to_pool(Elftc_String_Table *st, const char *string)
{
char *newpool;
- int len, newsize, stlen;
+ size_t len, newsize, stlen;
len = strlen(string) + 1; /* length, including the trailing NUL */
stlen = ELFTC_STRING_TABLE_LENGTH(st);
@@ -126,10 +126,10 @@ elftc_string_table_add_to_pool(Elftc_String_Table *st,
}
Elftc_String_Table *
-elftc_string_table_create(int sizehint)
+elftc_string_table_create(size_t sizehint)
{
- int n, nbuckets, tablesize;
struct _Elftc_String_Table *st;
+ int n, nbuckets, tablesize;
if (sizehint < ELFTC_STRING_TABLE_DEFAULT_SIZE)
sizehint = ELFTC_STRING_TABLE_DEFAULT_SIZE;
@@ -173,13 +173,13 @@ elftc_string_table_destroy(Elftc_String_Table *st)
}
Elftc_String_Table *
-elftc_string_table_from_section(Elf_Scn *scn, int sizehint)
+elftc_string_table_from_section(Elf_Scn *scn, size_t sizehint)
{
- int len;
Elf_Data *d;
GElf_Shdr sh;
const char *s, *end;
Elftc_String_Table *st;
+ size_t len;
/* Verify the type of the section passed in. */
if (gelf_getshdr(scn, &sh) == NULL ||
@@ -235,7 +235,8 @@ elftc_string_table_image(Elftc_String_Table *st, size_
char *r, *s, *end;
struct _Elftc_String_Table_Entry *ste;
struct _Elftc_String_Table_Bucket *head;
- int copied, hashindex, offset, length, newsize;
+ size_t copied, offset, length, newsize;
+ int hashindex;
/*
* For the common case of a string table has not seen
@@ -303,8 +304,9 @@ elftc_string_table_image(Elftc_String_Table *st, size_
size_t
elftc_string_table_insert(Elftc_String_Table *st, const char *string)
{
- int hashindex, idx;
struct _Elftc_String_Table_Entry *ste;
+ ssize_t idx;
+ int hashindex;
hashindex = 0;
@@ -326,7 +328,7 @@ elftc_string_table_insert(Elftc_String_Table *st, cons
idx = ste->ste_idx;
if (idx < 0) /* Undelete. */
- ste->ste_idx = idx = (- idx);
+ ste->ste_idx = idx = -idx;
return (idx);
}
@@ -334,8 +336,9 @@ elftc_string_table_insert(Elftc_String_Table *st, cons
size_t
elftc_string_table_lookup(Elftc_String_Table *st, const char *string)
{
- int hashindex, idx;
struct _Elftc_String_Table_Entry *ste;
+ ssize_t idx;
+ int hashindex;
ste = elftc_string_table_find_hash_entry(st, string, &hashindex);
@@ -350,17 +353,17 @@ elftc_string_table_lookup(Elftc_String_Table *st, cons
int
elftc_string_table_remove(Elftc_String_Table *st, const char *string)
{
- int idx;
struct _Elftc_String_Table_Entry *ste;
+ ssize_t idx;
ste = elftc_string_table_find_hash_entry(st, string, NULL);
if (ste == NULL || (idx = ste->ste_idx) < 0)
return (ELFTC_FAILURE);
- assert(idx > 0 && idx < (int) ELFTC_STRING_TABLE_LENGTH(st));
+ assert(idx > 0 && (size_t)idx < ELFTC_STRING_TABLE_LENGTH(st));
- ste->ste_idx = (- idx);
+ ste->ste_idx = -idx;
ELFTC_STRING_TABLE_SET_COMPACTION_FLAG(st);
Modified: stable/12/contrib/elftoolchain/libelftc/elftc_string_table_create.3
==============================================================================
--- stable/12/contrib/elftoolchain/libelftc/elftc_string_table_create.3 Wed Jul 3 20:53:05 2019 (r349707)
+++ stable/12/contrib/elftoolchain/libelftc/elftc_string_table_create.3 Wed Jul 3 20:54:36 2019 (r349708)
@@ -24,7 +24,7 @@
.\"
.\" $Id: elftc_string_table_create.3 3645 2018-10-15 20:17:14Z jkoshy $
.\"
-.Dd January 5, 2013
+.Dd June 19, 2019
.Dt ELFTC_STRING_TABLE_CREATE 3
.Os
.Sh NAME
@@ -40,11 +40,11 @@
.Sh SYNOPSIS
.In libelftc.h
.Ft "Elftc_String_Table *"
-.Fn elftc_string_table_create "int sizehint"
+.Fn elftc_string_table_create "size_t sizehint"
.Ft int
.Fn elftc_string_table_destroy "Elftc_String_Table *table"
.Ft "Elftc_String_Table *"
-.Fn elftc_string_table_from_section "Elf_Scn *scn" "int sizehint"
+.Fn elftc_string_table_from_section "Elf_Scn *scn" "size_t sizehint"
.Ft "const char *"
.Fo elftc_string_table_image
.Fa "Elftc_String_Table *table"
Modified: stable/12/contrib/elftoolchain/libelftc/libelftc.h
==============================================================================
--- stable/12/contrib/elftoolchain/libelftc/libelftc.h Wed Jul 3 20:53:05 2019 (r349707)
+++ stable/12/contrib/elftoolchain/libelftc/libelftc.h Wed Jul 3 20:54:36 2019 (r349708)
@@ -77,10 +77,10 @@ int elftc_demangle(const char *_mangledname, char *_b
size_t _bufsize, unsigned int _flags);
const char *elftc_reloc_type_str(unsigned int mach, unsigned int type);
int elftc_set_timestamps(const char *_filename, struct stat *_sb);
-Elftc_String_Table *elftc_string_table_create(int _hint);
+Elftc_String_Table *elftc_string_table_create(size_t _sizehint);
void elftc_string_table_destroy(Elftc_String_Table *_table);
Elftc_String_Table *elftc_string_table_from_section(Elf_Scn *_scn,
- int _hint);
+ size_t _sizehint);
const char *elftc_string_table_image(Elftc_String_Table *_table,
size_t *_sz);
size_t elftc_string_table_insert(Elftc_String_Table *_table,
More information about the svn-src-all
mailing list