[sysprof: 24/63] libsysprof-capture: Assert rather than calling g_warning()



commit e4813cd7292807961259de6c2321f5fbd7950ef9
Author: Philip Withnall <withnall endlessm com>
Date:   Thu Jul 2 09:54:16 2020 +0100

    libsysprof-capture: Assert rather than calling g_warning()
    
    Calling this function without having registered the counter beforehand
    seems reasonable to call a programmer error.
    
    Signed-off-by: Philip Withnall <withnall endlessm com>
    
    Helps: #40

 src/libsysprof-capture/sysprof-capture-writer.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
---
diff --git a/src/libsysprof-capture/sysprof-capture-writer.c b/src/libsysprof-capture/sysprof-capture-writer.c
index cb8c90a..8cd8898 100644
--- a/src/libsysprof-capture/sysprof-capture-writer.c
+++ b/src/libsysprof-capture/sysprof-capture-writer.c
@@ -1224,12 +1224,8 @@ sysprof_capture_writer_define_counters (SysprofCaptureWriter        *self,
 
   for (i = 0; i < n_counters; i++)
     {
-      if (counters[i].id >= self->next_counter_id)
-        {
-          g_warning ("Counter %u has not been registered.", counters[i].id);
-          continue;
-        }
-
+      /* Has the counter been registered? */
+      assert (counters[i].id < self->next_counter_id);
       def->counters[i] = counters[i];
     }
 


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