Skip to content

Commit

Permalink
Further efforts to keep GCC 8 happy
Browse files Browse the repository at this point in the history
  • Loading branch information
jonclayden committed Nov 12, 2018
1 parent 61884e2 commit 4f0066d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/dcm2niix/nii_dicom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,9 +649,9 @@ int headerDcm2Nii2(struct TDICOMdata d, struct TDICOMdata d2, struct nifti_1_hea
sprintf(dtxt, ";mb=%d", d.CSA.multiBandFactor);
strcat(txt,dtxt);
}
// GCC 8 warns about truncation using snprintf; using strncpy instead seems to keep it happy
// GCC 8 warns about truncation using snprintf
// snprintf(h->descrip,80, "%s",txt);
strncpy(h->descrip, txt, 79);
memcpy(h->descrip, txt, 79);
h->descrip[79] = '\0';

if (strlen(d.imageComments) > 0)
Expand Down Expand Up @@ -5524,7 +5524,7 @@ double TE = 0.0; //most recent echo time recorded
// 20161117131643.80000 -> date 20161117 time 131643.80000
//printMessage("acquisitionDateTime %s\n",acquisitionDateTimeTxt);
char acquisitionDateTxt[kDICOMStr];
strncpy(acquisitionDateTxt, acquisitionDateTimeTxt, kYYYYMMDDlen);
memcpy(acquisitionDateTxt, acquisitionDateTimeTxt, kYYYYMMDDlen);
acquisitionDateTxt[kYYYYMMDDlen] = '\0'; // IMPORTANT!
d.acquisitionDate = atof(acquisitionDateTxt);
char acquisitionTimeTxt[kDICOMStr];
Expand Down

0 comments on commit 4f0066d

Please sign in to comment.