[pacman-dev] INFRQ_* confusion
Hi! The constants defined in db.h are not usual: First, it seems logical, that NONE==0x0, ALL=0xFF. However you may forget about this, like be_files.c (row 222): "if(info->infolevel & inforeq) { /* already loaded this info, do nothing */ return(0); }" As I see, the author thinks of inforeq as exactly one bit is set to 1. However, if inforeq=0xFF and infolevel!=0, this is a bug. And if inforeq=0, this condition is never true. Bye.
On 2/28/07, Nagy Gabor <ngaba@petra.hos.u-szeged.hu> wrote:
As I see, the author thinks of inforeq as exactly one bit is set to 1. However, if inforeq=0xFF and infolevel!=0, this is a bug. And if inforeq=0, this condition is never true.
There is a bug here, but it's not what you're explaining. info->infolevel is |= to the new inforeq flags. This makes the and process work UNLESS infolevel is a composite (more than one flag). The real bug is here: - if(info->infolevel & inforeq) { + if(inforeq ^= (info->infolevel & inforeq)) { for example: info->infolevel == 1011 inforeq == 0111 & result == 0011 (so something is already loaded) ^= result == 0100 (exactly what we want, the missing piece)
On 2/28/07, Aaron Griffin <aaronmgriffin@gmail.com> wrote:
On 2/28/07, Nagy Gabor <ngaba@petra.hos.u-szeged.hu> wrote:
As I see, the author thinks of inforeq as exactly one bit is set to 1. However, if inforeq=0xFF and infolevel!=0, this is a bug. And if inforeq=0, this condition is never true.
There is a bug here, but it's not what you're explaining. info->infolevel is |= to the new inforeq flags. This makes the and process work UNLESS infolevel is a composite (more than one flag).
The real bug is here: - if(info->infolevel & inforeq) { + if(inforeq ^= (info->infolevel & inforeq)) {
for example: info->infolevel == 1011 inforeq == 0111 & result == 0011 (so something is already loaded) ^= result == 0100 (exactly what we want, the missing piece)
Ack, the if() condition needs to be reversed too, if(!...)
On 2/28/07, Aaron Griffin <aaronmgriffin@gmail.com> wrote:
On 2/28/07, Aaron Griffin <aaronmgriffin@gmail.com> wrote:
On 2/28/07, Nagy Gabor <ngaba@petra.hos.u-szeged.hu> wrote:
As I see, the author thinks of inforeq as exactly one bit is set to 1. However, if inforeq=0xFF and infolevel!=0, this is a bug. And if inforeq=0, this condition is never true.
There is a bug here, but it's not what you're explaining. info->infolevel is |= to the new inforeq flags. This makes the and process work UNLESS infolevel is a composite (more than one flag).
The real bug is here: - if(info->infolevel & inforeq) { + if(inforeq ^= (info->infolevel & inforeq)) {
for example: info->infolevel == 1011 inforeq == 0111 & result == 0011 (so something is already loaded) ^= result == 0100 (exactly what we want, the missing piece)
Ack, the if() condition needs to be reversed too, if(!...)
Does this still need following up on? -Dan
On 3/1/07, Dan McGee <dpmcgee@gmail.com> wrote:
On 2/28/07, Aaron Griffin <aaronmgriffin@gmail.com> wrote:
On 2/28/07, Aaron Griffin <aaronmgriffin@gmail.com> wrote:
On 2/28/07, Nagy Gabor <ngaba@petra.hos.u-szeged.hu> wrote:
As I see, the author thinks of inforeq as exactly one bit is set to 1. However, if inforeq=0xFF and infolevel!=0, this is a bug. And if inforeq=0, this condition is never true.
There is a bug here, but it's not what you're explaining. info->infolevel is |= to the new inforeq flags. This makes the and process work UNLESS infolevel is a composite (more than one flag).
The real bug is here: - if(info->infolevel & inforeq) { + if(inforeq ^= (info->infolevel & inforeq)) {
for example: info->infolevel == 1011 inforeq == 0111 & result == 0011 (so something is already loaded) ^= result == 0100 (exactly what we want, the missing piece)
Ack, the if() condition needs to be reversed too, if(!...)
Does this still need following up on?
No, I'm going to take care of it tonight with a bunch of other INFRQ related changes.
Hi! We talked about this problem, so here is my patch: db.h.diff: ========== --- db.h.old 2007-03-10 01:00:38.000000000 +0100 +++ db.h 2007-03-10 01:02:04.000000000 +0100 @@ -33,7 +33,7 @@ INFRQ_DEPENDS = 0x04, INFRQ_FILES = 0x08, INFRQ_SCRIPTLET = 0x10, - INFRQ_ALL = 0xFF + INFRQ_ALL = 0x1F } pmdbinfrq_t; /* Database */ be_files.c.diff: ================ --- be_files.c.old 2007-03-10 01:00:38.000000000 +0100 +++ be_files.c 2007-03-10 00:58:38.000000000 +0100 @@ -227,7 +227,7 @@ return(-1); } - if(info->infolevel & inforeq) { + if(!(~(info->infolevel) & inforeq & INFRQ_ALL)) { /* already loaded this info, do nothing */ return(0); } ================= Bye, Nagy Gabor
On Wed, 28 Feb 2007, Aaron Griffin wrote:
On 2/28/07, Aaron Griffin <aaronmgriffin@gmail.com> wrote:
On 2/28/07, Nagy Gabor <ngaba@petra.hos.u-szeged.hu> wrote:
As I see, the author thinks of inforeq as exactly one bit is set to 1. However, if inforeq=0xFF and infolevel!=0, this is a bug. And if inforeq=0, this condition is never true.
There is a bug here, but it's not what you're explaining. info->infolevel is |= to the new inforeq flags. This makes the and process work UNLESS infolevel is a composite (more than one flag).
The real bug is here: - if(info->infolevel & inforeq) { + if(inforeq ^= (info->infolevel & inforeq)) {
for example: info->infolevel == 1011 inforeq == 0111 & result == 0011 (so something is already loaded) ^= result == 0100 (exactly what we want, the missing piece)
Or an equivalent form: if(~infolevel & inforeq) ... But be careful, because it is not exactly what you want. You should first use a bitmask to clear the not used bits. For example if infolevel==0xF and inforeq==infrq_all, you conclude that more info is needed (I assumed that the 0-3 bits used). Bye, Nagy Gabor
participants (3)
-
Aaron Griffin
-
Dan McGee
-
Nagy Gabor