Skip to content

Commit

Permalink
Avoid pointer cast to time_t from incompatible type (#427)
Browse files Browse the repository at this point in the history
Resolves #426

cherry-pick 235a267
  • Loading branch information
plexoos committed Feb 19, 2024
1 parent f7156c1 commit 50a7ab3
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 19 deletions.
5 changes: 3 additions & 2 deletions StRoot/StDaqLib/SC/SC_Reader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <assert.h>
#include <math.h>
#include <ctime>

using namespace OLDEVP;

Expand Down Expand Up @@ -97,8 +98,8 @@ SC_Reader::SC_Reader(EventReader *er) {
//Keep BBCBkg scalers flipped as theyStRoot/StDaqLib/SC/SC_Reader.cxx were historically before 2009
//Note that new DAQ reader leads to UTime = 0, or tm_year=70 (1970)
//but new DAQ reader only gets used for 2009+ anyhow
unsigned int UTime = er->getEventInfo().UnixTime;
struct tm *time=gmtime((time_t*) &UTime);
std::time_t utime = er->getEventInfo().UnixTime;
std::tm *time = gmtime(&utime);
flipBBCBkg = (time->tm_year > 95 && time->tm_year < 109 ? 1 : 0) ;

// LDate = (((1900+time->tm_year)*100 + 1 + time->tm_mon)*100 + time->tm_mday)*100;
Expand Down
5 changes: 3 additions & 2 deletions StRoot/StDaqLib/SSD/SSD_Reader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <assert.h>
#include <math.h>
#include <ctime>

static unsigned short log8to10_table[256] = {
0, 1, 2, 3, 4, 5, 6, 7,
Expand Down Expand Up @@ -118,8 +119,8 @@ SSD_Reader::SSD_Reader(EventReader *er) {
datap=er->getDATAP();
if (datap) {

unsigned int UTime = er->getEventInfo().UnixTime;
struct tm *time=gmtime((time_t*) &UTime);
std::time_t utime = er->getEventInfo().UnixTime;
std::tm *time = gmtime(&utime);

//LDate = (((1900+time->tm_year)*100 + 1 + time->tm_mon)*100 + time->tm_mday)*100;
//LDate = yyyymmdd
Expand Down
4 changes: 3 additions & 1 deletion StRoot/StEEmcUtil/EEfeeRaw/RootWrapper.cxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <cstdlib>
#include <cstdio>
#include <ctime>

#include "TROOT.h"
#include "TFile.h"
Expand Down Expand Up @@ -57,7 +58,8 @@ eemcfeerootopen_(long& run, long& runtime, char *chfile, int &nAuto, int len)
char *idt = strchr(basefile,'.'); *idt = 0x00; // locate first dot
}
sprintf(filename,"%s/%s.ez.root",rootdir,basefile);
sprintf(comment,"run:%05ld, time:%s ",run,ctime((time_t *)&runtime));
std::time_t utime = runtime;
sprintf(comment,"run:%05ld, time:%s ",run,ctime(&utime));

file = new TFile(filename,"RECREATE");
tree = new TTree("ezstar","A tree with FEE events");
Expand Down
4 changes: 2 additions & 2 deletions StRoot/St_trg_Maker/year2003.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ void St_trg_Maker::Emc2003(St_dst_TrgDet *dst1) {
//pp_dsm_to_patch[7] for after 01-Dec-2001, AA_dsm_to_patch[5] for before that date
EventReader *er=fVictorPrelim->getEventReader();
EventInfo info=er->getEventInfo();
unsigned int UnixTime=info.UnixTime;
struct tm *time=gmtime((time_t*) &UnixTime);
std::time_t utime = info.UnixTime;
std::tm *time = gmtime(&utime);
int year=1900+time->tm_year;
int month=1+time->tm_mon;
int day=time->tm_mday;
Expand Down
23 changes: 11 additions & 12 deletions StRoot/StarRoot/TUnixTime.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
*
***************************************************************************
**************************************************************************/
#include <ctime>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <assert.h>
#include "TUnixTime.h"
#include "TDatime.h"
Expand Down Expand Up @@ -111,30 +111,29 @@ void TUnixTime::SetLTime(Int_t idate, Int_t itime)
//______________________________________________________________________________
void TUnixTime::GetGTime(Int_t &idate, Int_t &itime)
{
struct tm gt;
gt = *gmtime((time_t*)&fUTime);
tm2DateTime(idate,itime,&gt);
std::time_t utime = fUTime;
std::tm *gt = gmtime(&utime);
tm2DateTime(idate, itime, gt);

}
//______________________________________________________________________________
void TUnixTime::GetLTime(Int_t &idate, Int_t &itime)
{
struct tm gt;
gt = *localtime((time_t*)&fUTime);
tm2DateTime(idate,itime,&gt);

std::time_t utime = fUTime;
std::tm *gt = localtime(&utime);
tm2DateTime(idate, itime, gt);
}
//______________________________________________________________________________
TString TUnixTime::GetLString()
{
TString ts(ctime((time_t*)&fUTime));
return ts;
std::time_t utime = fUTime;
return TString(ctime(&utime));
}
//______________________________________________________________________________
TString TUnixTime::GetGString()
{
TString ts(asctime(gmtime((time_t*)&fUTime)));
return ts;
std::time_t utime = fUTime;
return TString(asctime(gmtime(&utime)));
}
//______________________________________________________________________________
void TUnixTime::SetLTime(const TDatime &loc)
Expand Down

0 comments on commit 50a7ab3

Please sign in to comment.