Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e7847d35 authored by Fabio M. Di Nitto's avatar Fabio M. Di Nitto Committed by David Teigland
Browse files

dlm: align midcomms message buffer



gcc does not guarantee that an auto buffer is 64bit aligned.
This change allows sparc64 to work.

Signed-off-by: default avatarFabio M. Di Nitto <fabbione@ubuntu.com>
Signed-off-by: default avatarDavid Teigland <teigland@redhat.com>
parent 39bd4177
Loading
Loading
Loading
Loading
+9 −6
Original line number Original line Diff line number Diff line
@@ -2,7 +2,7 @@
*******************************************************************************
*******************************************************************************
**
**
**  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.
**  Copyright (C) Sistina Software, Inc.  1997-2003  All rights reserved.
**  Copyright (C) 2004-2007 Red Hat, Inc.  All rights reserved.
**  Copyright (C) 2004-2008 Red Hat, Inc.  All rights reserved.
**
**
**  This copyrighted material is made available to anyone wishing to use,
**  This copyrighted material is made available to anyone wishing to use,
**  modify, copy, or redistribute it subject to the terms and conditions
**  modify, copy, or redistribute it subject to the terms and conditions
@@ -58,8 +58,12 @@ static void copy_from_cb(void *dst, const void *base, unsigned offset,
int dlm_process_incoming_buffer(int nodeid, const void *base,
int dlm_process_incoming_buffer(int nodeid, const void *base,
				unsigned offset, unsigned len, unsigned limit)
				unsigned offset, unsigned len, unsigned limit)
{
{
	unsigned char __tmp[DLM_INBUF_LEN];
	union {
	struct dlm_header *msg = (struct dlm_header *) __tmp;
		unsigned char __buf[DLM_INBUF_LEN];
		/* this is to force proper alignment on some arches */
		struct dlm_header dlm;
	} __tmp;
	struct dlm_header *msg = &__tmp.dlm;
	int ret = 0;
	int ret = 0;
	int err = 0;
	int err = 0;
	uint16_t msglen;
	uint16_t msglen;
@@ -100,8 +104,7 @@ int dlm_process_incoming_buffer(int nodeid, const void *base,
		   in the buffer on the stack (which should work for most
		   in the buffer on the stack (which should work for most
		   ordinary messages). */
		   ordinary messages). */


		if (msglen > sizeof(__tmp) &&
		if (msglen > DLM_INBUF_LEN && msg == &__tmp.dlm) {
		    msg == (struct dlm_header *) __tmp) {
			msg = kmalloc(dlm_config.ci_buffer_size, GFP_KERNEL);
			msg = kmalloc(dlm_config.ci_buffer_size, GFP_KERNEL);
			if (msg == NULL)
			if (msg == NULL)
				return ret;
				return ret;
@@ -119,7 +122,7 @@ int dlm_process_incoming_buffer(int nodeid, const void *base,
		dlm_receive_buffer(msg, nodeid);
		dlm_receive_buffer(msg, nodeid);
	}
	}


	if (msg != (struct dlm_header *) __tmp)
	if (msg != &__tmp.dlm)
		kfree(msg);
		kfree(msg);


	return err ? err : ret;
	return err ? err : ret;