Bug 209305 - Code to malloc should use struct <NAME> instead of pointer as per style guidelines
Summary: Code to malloc should use struct <NAME> instead of pointer as per style guide...
Status: Closed Not A Bug
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Many People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-05 20:22 UTC by Shawn Debnath
Modified: 2016-05-05 20:44 UTC (History)
0 users

See Also:


Attachments
Patch for malloc using struct (391 bytes, patch)
2016-05-05 20:22 UTC, Shawn Debnath
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Shawn Debnath 2016-05-05 20:22:28 UTC
Created attachment 170020 [details]
Patch for malloc using struct

In efipart.c, the code to malloc the phys dev info (struct pdinfo) is allocated via:

   malloc(nin * sizeof(*pdinfo));

It should be

  malloc(nin * sizeof(struct pdinfo));

according to style(9) and in general code guidelines in FreeBSD
Comment 1 Shawn Debnath 2016-05-05 20:25:39 UTC
Review: https://reviews.freebsd.org/D6233
Comment 2 Shawn Debnath 2016-05-05 20:44:03 UTC
Better to use variable to obtain size to allocate so that in the future if variable type changes, compiler's won't produce warnings and harder to track down.