[sysprof: 32/63] libsysprof-capture: Use offsetof() rather than G_STRUCT_OFFSET()



commit 3446628cecb2c341ab1ee620f25ce0d5384e5519
Author: Philip Withnall <withnall endlessm com>
Date:   Thu Jul 2 11:00:14 2020 +0100

    libsysprof-capture: Use offsetof() rather than G_STRUCT_OFFSET()
    
    It does the same for modern compilers.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>
    
    Helps: #40

 src/libsysprof-capture/sysprof-capture-writer-cat.c | 2 +-
 src/libsysprof-capture/sysprof-capture-writer.c     | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)
---
diff --git a/src/libsysprof-capture/sysprof-capture-writer-cat.c 
b/src/libsysprof-capture/sysprof-capture-writer-cat.c
index 3fbd585..cec252a 100644
--- a/src/libsysprof-capture/sysprof-capture-writer-cat.c
+++ b/src/libsysprof-capture/sysprof-capture-writer-cat.c
@@ -366,7 +366,7 @@ sysprof_capture_writer_cat (SysprofCaptureWriter  *self,
                                                  frame->frame.pid,
                                                  frame->id,
                                                  frame->metadata,
-                                                 frame->frame.len - G_STRUCT_OFFSET (SysprofCaptureMetadata, 
metadata));
+                                                 frame->frame.len - offsetof (SysprofCaptureMetadata, 
metadata));
             break;
           }
 
diff --git a/src/libsysprof-capture/sysprof-capture-writer.c b/src/libsysprof-capture/sysprof-capture-writer.c
index 1e27729..953328e 100644
--- a/src/libsysprof-capture/sysprof-capture-writer.c
+++ b/src/libsysprof-capture/sysprof-capture-writer.c
@@ -904,7 +904,7 @@ again:
   ret = _sysprof_pwrite (self->fd,
                          &end_time,
                          sizeof (end_time),
-                         G_STRUCT_OFFSET (SysprofCaptureFileHeader, end_time));
+                         offsetof (SysprofCaptureFileHeader, end_time));
 
   if (ret < 0 && errno == EAGAIN)
     goto again;
@@ -1341,7 +1341,7 @@ do_start:
   ret = _sysprof_pwrite (self->fd,
                          &start_time,
                          sizeof (start_time),
-                         G_STRUCT_OFFSET (SysprofCaptureFileHeader, time));
+                         offsetof (SysprofCaptureFileHeader, time));
 
   if (ret < 0 && errno == EAGAIN)
     goto do_start;
@@ -1350,7 +1350,7 @@ do_end:
   ret = _sysprof_pwrite (self->fd,
                          &end_time,
                          sizeof (end_time),
-                         G_STRUCT_OFFSET (SysprofCaptureFileHeader, end_time));
+                         offsetof (SysprofCaptureFileHeader, end_time));
 
   if (ret < 0 && errno == EAGAIN)
     goto do_end;


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