diff mbox

[LEDE-DEV,ubox] remove unnecessary size struct between messages

Message ID 1465294276-15925-1-git-send-email-danutbug@gmail.com
State Rejected
Delegated to: John Crispin
Headers show

Commit Message

dbugnar June 7, 2016, 10:11 a.m. UTC
From: Dan Bugnar <dnbugnar@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@gmail.com>
---
 log/syslog.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

John Crispin July 1, 2016, 5:38 a.m. UTC | #1
On 07/06/2016 12:11, Dan Bugnar wrote:
> From: Dan Bugnar <dnbugnar@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@gmail.com>

coming back to these patches, i fail to see why you remove the padding.
this will guarantee that struct log_head pointers are always 4 byte
aligned, thus preventing unaligned accesses from happening. imho the
code should nt be changed, it is there for a reason.

	John

> ---
>  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];
>  
>  	return (n >= log_end) ? (log) : (n);
>  }
>
diff mbox

Patch

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];
 
 	return (n >= log_end) ? (log) : (n);
 }