[LEDE-DEV] [PATCH 1/3] [ubox] remove unnecessary size struct between messages

Alexandru Ardelean ardeleanalex at gmail.com
Sat Jun 4 03:40:53 PDT 2016


On Fri, Jun 3, 2016 at 2:27 PM, Conor O'Gorman <i at conorogorman.net> wrote:
> On 03/06/16 11:59, Dan Bugnar wrote:
>>
>> From: Dan Bugnar <dnbugnar at ocedo.com>
>>
>> The next message needs to be written after the data of current message.
>> This was adding "sizeof(struct log_head)" bytes between messages.
>>
>> Signed-off-by: Dan Bugnar <danutbug at gmail.com>
>> ---
>>   log/syslog.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/log/syslog.c b/log/syslog.c
>> index e8b6774..2042e93 100644
>> --- a/log/syslog.c
>> +++ b/log/syslog.c
>> @@ -51,7 +51,7 @@ static regex_t pat_tstamp;
>>   static struct log_head*
>>   log_next(struct log_head *h, int size)
>>   {
>> -       struct log_head *n = (struct log_head *)
>> &h->data[PAD(sizeof(struct log_head) + size)];
>> +       struct log_head *n = (struct log_head *) &h->data[size];
>>
> You lost the PAD? Which is over the struct and size, not just the struct.
>
> Conor
>
>
> _______________________________________________
> Lede-dev mailing list
> Lede-dev at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/lede-dev

hmm, what about moving the PAD() somewhere in the log_add() function ?
it would save some cycles, since, that's the only place where the size
would need to be adjusted for padding/alignment;
doing it in log_next(), can be a bit CPU expensive

as for the comment "Which is over the struct and size, not just the struct."
i am bit unclear;
apologies if i'll be too verbose (below)

this change is good (padding aside)
previously, the log_next() function would jump over "sizeof(struct
log_head) + PAD(sizeof(struct log_head) + size)"
the "data" field in the struct log_head is at the end of the struct
(offset sizeof(struct log_head) )
there should be no need to also jump "sizeof(struct log_head)"  in the
"data" field
basically, it would punch "sizeof(struct log_head)" holes (i think 20
bytes each) in the log buffer, between entries



More information about the Lede-dev mailing list