Re: [PATCH v2 21/27] xfsprogs: Remove single byte array from struct parent

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 06/10/2018 04:21 AM, Amir Goldstein wrote:
On Sun, Jun 10, 2018 at 8:07 AM, Allison Henderson
<allison.henderson@xxxxxxxxxx> wrote:
Variable sized arrays implemented this way may cause
corruptions depending on how different compilers pack
the structure.

Signed-off-by: Allison Henderson <allison.henderson@xxxxxxxxxx>
---
  include/parent.h | 1 -
  io/parent.c      | 9 ++++++---
  2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/parent.h b/include/parent.h
index f338f96..85cef85 100644
--- a/include/parent.h
+++ b/include/parent.h
@@ -22,7 +22,6 @@ typedef struct parent {
         __u64   p_ino;
         __u32   p_gen;
         __u16   p_reclen;
-       char    p_name[1];

How about
    char    p_name[0];

Is that also risky? keeps the code cleaner IMO.
Second best, at least have a macro to access p_name
instead of open coding ((char*)parent)+sizeof(struct parent))
all the time. First option is much better IMO.

Thanks,
Amir.


Oh yes, I think there was some discussion about not using declarations like that in a previous review of the set last year. Initially I had applied the same logic here to sort of prepare these older structs for use in an alternate solution to patch 26, but then later adopted Darricks solution that does not require then. I could probably drop this patch from the set since this code is removed in patch 27. Thx for the catch though!

Allison
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux