Back Midas Rome Roody Rootana
  Midas DAQ System  Not logged in ELOG logo
Entry  14 Nov 2024, Mann Gandhi, Suggestion, Issue with creating banks Screenshot_from_2024-11-14_12-35-06.png
    Reply  14 Nov 2024, Stefan Ritt, Suggestion, Issue with creating banks 
       Reply  14 Nov 2024, Mann Gandhi, Suggestion, Issue with creating banks 
    Reply  15 Nov 2024, Konstantin Olchanski, Suggestion, Issue with creating banks 
Message ID: 2896     Entry time: 15 Nov 2024     In reply to: 2893
Author: Konstantin Olchanski 
Topic: Suggestion 
Subject: Issue with creating banks 
> Hello, I am a coop student working at SNOLAB.
> void* data_acquisition_thread(void* param)
> {
> 	EVENT_HEADER *pevent;
>       if (complicated) {
> 			status = rb_get_wp(rbh, (void **) &pevent, 0);
>       }
>       bm_compose_event_threadsafe(pevent, 1, 0, 0, &equipment[0].serial_number);
> }

this code is buggy. it should read "EVENT_HEADER *pevent = NULL;" to avoid an uninitialized variable
and bm_compose_event() & co should be inside an "if (pevent != NULL)" block, unless you can absolutely
proove that rb_get_wp() is always called and pevent is never NULL. (even is somebody changes the code later).

if you build your code with "gcc -O2 -g -Wall -Wuninitialized" it would probably warn you about use of uninitilialized 
"pevent".

P.S. for building multithreaded frontends, you are much better off starting from the c++ tmfe frontend framework,
a good starting point is study tmfe_example_everything.cxx.

K.O.
ELOG V3.1.4-2e1708b5