[Drbd-dev] [PATCH 13/13] DRBD-receiver: Improve determination of sizes in receive_Barrier()

SF Markus Elfring elfring at users.sourceforge.net
Sat Sep 10 22:36:51 CEST 2016


From: Markus Elfring <elfring at users.sourceforge.net>
Date: Sat, 10 Sep 2016 22:06:21 +0200

Replace the specification of data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring at users.sourceforge.net>
---
 drivers/block/drbd/drbd_receiver.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index e4da335..32ac4a9 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -1747,7 +1747,7 @@ static int receive_Barrier(struct drbd_connection *connection, struct packet_inf
 
 		/* receiver context, in the writeout path of the other node.
 		 * avoid potential distributed deadlock */
-		epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
+		epoch = kmalloc(sizeof(*epoch), GFP_NOIO);
 		if (epoch)
 			break;
 		else
@@ -1760,7 +1760,7 @@ static int receive_Barrier(struct drbd_connection *connection, struct packet_inf
 		drbd_flush(connection);
 
 		if (atomic_read(&connection->current_epoch->epoch_size)) {
-			epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
+			epoch = kmalloc(sizeof(*epoch), GFP_NOIO);
 			if (epoch)
 				break;
 		}
-- 
2.10.0



More information about the drbd-dev mailing list