Skip to content

Instantly share code, notes, and snippets.

@kaworu
Created March 26, 2013 08:58
Show Gist options
  • Save kaworu/5244008 to your computer and use it in GitHub Desktop.
Save kaworu/5244008 to your computer and use it in GitHub Desktop.
pkgng patch
diff --git a/external/libelf/elf_update.c b/external/libelf/elf_update.c
index 900ed2a..d5d41e3 100644
--- a/external/libelf/elf_update.c
+++ b/external/libelf/elf_update.c
@@ -502,7 +502,7 @@ _libelf_resync_sections(Elf *e, off_t rc, struct _Elf_Extent_List *extents)
static off_t
_libelf_resync_elf(Elf *e, struct _Elf_Extent_List *extents)
{
- int ec, eh_class, eh_type;
+ int ec, eh_class;
unsigned int eh_byteorder, eh_version;
size_t align, fsz;
size_t phnum, shnum;
@@ -531,14 +531,12 @@ _libelf_resync_elf(Elf *e, struct _Elf_Extent_List *extents)
eh_class = eh32->e_ident[EI_CLASS];
phoff = (uint64_t) eh32->e_phoff;
shoff = (uint64_t) eh32->e_shoff;
- eh_type = eh32->e_type;
eh_version = eh32->e_version;
} else {
eh_byteorder = eh64->e_ident[EI_DATA];
eh_class = eh64->e_ident[EI_CLASS];
phoff = eh64->e_phoff;
shoff = eh64->e_shoff;
- eh_type = eh64->e_type;
eh_version = eh64->e_version;
}
diff --git a/external/libelf/libelf_phdr.c b/external/libelf/libelf_phdr.c
index 8495e42..b9a59a5 100644
--- a/external/libelf/libelf_phdr.c
+++ b/external/libelf/libelf_phdr.c
@@ -38,7 +38,7 @@ ELFTC_VCSID("$Id: libelf_phdr.c 2225 2011-11-26 18:55:54Z jkoshy $");
void *
_libelf_getphdr(Elf *e, int ec)
{
- size_t phnum, phentsize;
+ size_t phnum;
size_t fsz, msz;
uint64_t phoff;
Elf32_Ehdr *eh32;
@@ -69,11 +69,9 @@ _libelf_getphdr(Elf *e, int ec)
if (ec == ELFCLASS32) {
eh32 = (Elf32_Ehdr *) ehdr;
- phentsize = eh32->e_phentsize;
phoff = (uint64_t) eh32->e_phoff;
} else {
eh64 = (Elf64_Ehdr *) ehdr;
- phentsize = eh64->e_phentsize;
phoff = (uint64_t) eh64->e_phoff;
}
diff --git a/external/uthash/uthash.h b/external/uthash/uthash.h
index fe2d51b..909cb0a 100644
--- a/external/uthash/uthash.h
+++ b/external/uthash/uthash.h
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2003-2013, Troy D. Hanson http://uthash.sourceforge.net
+Copyright (c) 2003-2013, Troy D. Hanson http://troydhanson.github.com/uthash/
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -64,7 +64,7 @@ typedef unsigned char uint8_t;
#include <inttypes.h> /* uint32_t */
#endif
-#define UTHASH_VERSION 1.9.7
+#define UTHASH_VERSION 1.9.8
#ifndef uthash_fatal
#define uthash_fatal(msg) exit(-1) /* fatal error (out of memory,etc) */
@@ -135,6 +135,7 @@ do {
#define HASH_BLOOM_FREE(tbl)
#define HASH_BLOOM_ADD(tbl,hashv)
#define HASH_BLOOM_TEST(tbl,hashv) (1)
+#define HASH_BLOOM_BYTELEN 0
#endif
#define HASH_MAKE_TABLE(hh,head) \
@@ -158,6 +159,16 @@ do {
#define HASH_ADD(hh,head,fieldname,keylen_in,add) \
HASH_ADD_KEYPTR(hh,head,&((add)->fieldname),keylen_in,add)
+
+#define HASH_REPLACE(hh,head,fieldname,keylen_in,add,replaced) \
+do { \
+ replaced=NULL; \
+ HASH_FIND(hh,head,&((add)->fieldname),keylen_in,replaced); \
+ if (replaced!=NULL) { \
+ HASH_DELETE(hh,head,replaced); \
+ }; \
+ HASH_ADD(hh,head,fieldname,keylen_in,add); \
+} while(0)
#define HASH_ADD_KEYPTR(hh,head,keyptr,keylen_in,add) \
do { \
@@ -242,14 +253,20 @@ do {
HASH_FIND(hh,head,findstr,strlen(findstr),out)
#define HASH_ADD_STR(head,strfield,add) \
HASH_ADD(hh,head,strfield,strlen(add->strfield),add)
+#define HASH_REPLACE_STR(head,strfield,add,replaced) \
+ HASH_REPLACE(hh,head,strfield,strlen(add->strfield),add,replaced)
#define HASH_FIND_INT(head,findint,out) \
HASH_FIND(hh,head,findint,sizeof(int),out)
#define HASH_ADD_INT(head,intfield,add) \
HASH_ADD(hh,head,intfield,sizeof(int),add)
+#define HASH_REPLACE_INT(head,intfield,add,replaced) \
+ HASH_REPLACE(hh,head,intfield,sizeof(int),add,replaced)
#define HASH_FIND_PTR(head,findptr,out) \
HASH_FIND(hh,head,findptr,sizeof(void *),out)
#define HASH_ADD_PTR(head,ptrfield,add) \
HASH_ADD(hh,head,ptrfield,sizeof(void *),add)
+#define HASH_REPLACE_PTR(head,ptrfield,add) \
+ HASH_REPLACE(hh,head,ptrfield,sizeof(void *),add,replaced)
#define HASH_DEL(head,delptr) \
HASH_DELETE(hh,head,delptr)
@@ -399,10 +416,10 @@ do {
#define HASH_JEN(key,keylen,num_bkts,hashv,bkt) \
do { \
unsigned _hj_i,_hj_j,_hj_k; \
- char *_hj_key=(char*)(key); \
+ unsigned char *_hj_key=(unsigned char*)(key); \
hashv = 0xfeedbeef; \
_hj_i = _hj_j = 0x9e3779b9; \
- _hj_k = (unsigned)keylen; \
+ _hj_k = (unsigned)keylen; \
while (_hj_k >= 12) { \
_hj_i += (_hj_key[0] + ( (unsigned)_hj_key[1] << 8 ) \
+ ( (unsigned)_hj_key[2] << 16 ) \
@@ -450,7 +467,7 @@ do {
#endif
#define HASH_SFH(key,keylen,num_bkts,hashv,bkt) \
do { \
- char *_sfh_key=(char*)(key); \
+ unsigned char *_sfh_key=(unsigned char*)(key); \
uint32_t _sfh_tmp, _sfh_len = keylen; \
\
int _sfh_rem = _sfh_len & 3; \
@@ -460,7 +477,7 @@ do {
/* Main loop */ \
for (;_sfh_len > 0; _sfh_len--) { \
hashv += get16bits (_sfh_key); \
- _sfh_tmp = (get16bits (_sfh_key+2) << 11) ^ hashv; \
+ _sfh_tmp = (uint32_t)(get16bits (_sfh_key+2)) << 11 ^ hashv; \
hashv = (hashv << 16) ^ _sfh_tmp; \
_sfh_key += 2*sizeof (uint16_t); \
hashv += hashv >> 11; \
@@ -470,7 +487,7 @@ do {
switch (_sfh_rem) { \
case 3: hashv += get16bits (_sfh_key); \
hashv ^= hashv << 16; \
- hashv ^= _sfh_key[sizeof (uint16_t)] << 18; \
+ hashv ^= (uint32_t)(_sfh_key[sizeof (uint16_t)] << 18); \
hashv += hashv >> 11; \
break; \
case 2: hashv += get16bits (_sfh_key); \
@@ -832,6 +849,12 @@ do {
} \
} while(0)
+#define HASH_OVERHEAD(hh,head) \
+ (size_t)((((head)->hh.tbl->num_items * sizeof(UT_hash_handle)) + \
+ ((head)->hh.tbl->num_buckets * sizeof(UT_hash_bucket)) + \
+ (sizeof(UT_hash_table)) + \
+ (HASH_BLOOM_BYTELEN)))
+
#ifdef NO_DECLTYPE
#define HASH_ITER(hh,head,el,tmp) \
for((el)=(head), (*(char**)(&(tmp)))=(char*)((head)?(head)->hh.next:NULL); \
diff --git a/external/uthash/utlist.h b/external/uthash/utlist.h
index 58bfcbc..6bccec7 100644
--- a/external/uthash/utlist.h
+++ b/external/uthash/utlist.h
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2007-2013, Troy D. Hanson http://uthash.sourceforge.net
+Copyright (c) 2007-2013, Troy D. Hanson http://troydhanson.github.com/uthash/
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -24,7 +24,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#ifndef UTLIST_H
#define UTLIST_H
-#define UTLIST_VERSION 1.9.7
+#define UTLIST_VERSION 1.9.8
#include <assert.h>
@@ -108,15 +108,12 @@ do {
LDECLTYPE(list) _ls_q; \
LDECLTYPE(list) _ls_e; \
LDECLTYPE(list) _ls_tail; \
- LDECLTYPE(list) _ls_oldhead; \
- LDECLTYPE(list) _tmp; \
int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \
if (list) { \
_ls_insize = 1; \
_ls_looping = 1; \
while (_ls_looping) { \
_CASTASGN(_ls_p,list); \
- _CASTASGN(_ls_oldhead,list); \
list = NULL; \
_ls_tail = NULL; \
_ls_nmerges = 0; \
@@ -153,13 +150,15 @@ do {
} \
_ls_p = _ls_q; \
} \
- _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,NULL,next); _RS(list); \
+ if (_ls_tail) { \
+ _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,NULL,next); _RS(list); \
+ } \
if (_ls_nmerges <= 1) { \
_ls_looping=0; \
} \
_ls_insize *= 2; \
} \
- } else _tmp=NULL; /* quiet gcc unused variable warning */ \
+ } \
} while (0)
@@ -172,15 +171,12 @@ do {
LDECLTYPE(list) _ls_q; \
LDECLTYPE(list) _ls_e; \
LDECLTYPE(list) _ls_tail; \
- LDECLTYPE(list) _ls_oldhead; \
- LDECLTYPE(list) _tmp; \
int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \
if (list) { \
_ls_insize = 1; \
_ls_looping = 1; \
while (_ls_looping) { \
_CASTASGN(_ls_p,list); \
- _CASTASGN(_ls_oldhead,list); \
list = NULL; \
_ls_tail = NULL; \
_ls_nmerges = 0; \
@@ -225,7 +221,7 @@ do {
} \
_ls_insize *= 2; \
} \
- } else _tmp=NULL; /* quiet gcc unused variable warning */ \
+ } \
} while (0)
#define CDL_SORT(list, cmp) \
@@ -239,7 +235,6 @@ do {
LDECLTYPE(list) _ls_tail; \
LDECLTYPE(list) _ls_oldhead; \
LDECLTYPE(list) _tmp; \
- LDECLTYPE(list) _tmp2; \
int _ls_insize, _ls_nmerges, _ls_psize, _ls_qsize, _ls_i, _ls_looping; \
if (list) { \
_ls_insize = 1; \
@@ -295,14 +290,14 @@ do {
_ls_p = _ls_q; \
} \
_CASTASGN(list->prev,_ls_tail); \
- _CASTASGN(_tmp2,list); \
- _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,_tmp2,next); _RS(list); \
+ _CASTASGN(_tmp,list); \
+ _SV(_ls_tail,list); _NEXTASGN(_ls_tail,list,_tmp,next); _RS(list); \
if (_ls_nmerges <= 1) { \
_ls_looping=0; \
} \
_ls_insize *= 2; \
} \
- } else _tmp=NULL; /* quiet gcc unused variable warning */ \
+ } \
} while (0)
/******************************************************************************
diff --git a/pkg/upgrade.c b/pkg/upgrade.c
index 3f17a0f..19aa1aa 100644
--- a/pkg/upgrade.c
+++ b/pkg/upgrade.c
@@ -48,7 +48,7 @@ exec_upgrade(int argc, char **argv)
{
struct pkgdb *db = NULL;
struct pkg_jobs *jobs = NULL;
- const char *reponame = NULL;
+ const char __unused *reponame = NULL;
int retcode;
int updcode;
int ch;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment