# HG changeset patch # User Matti Hamalainen # Date 1533558312 -10800 # Node ID 862a943afff4f6bab4a67b395f7be607290e023e # Parent bec158e00f17da0bf54ab65964fd0c5da61e9750 Fix some warnings in regards to strncpy(). diff -r bec158e00f17 -r 862a943afff4 src/dmengine.h --- a/src/dmengine.h Mon Jul 23 15:15:37 2018 +0300 +++ b/src/dmengine.h Mon Aug 06 15:25:12 2018 +0300 @@ -340,7 +340,7 @@ int dmCopyTimelineTrack(const DMTimelineTrack *src, DMTimelineTrack **pdst); int dmCopyTimeline(const DMTimeline *src, DMTimeline **pdst); -int dmSaveTimeline(DMResource *res, DMTimeline *tl); +int dmSaveTimeline(DMResource *res, const DMTimeline *tl); int dmTimelineNew(DMTimeline **tl, const char *name); int dmTimelineAddTrack(DMTimeline *tl, DMTimelineTrack **track, const char *name); diff -r bec158e00f17 -r 862a943afff4 src/dmtimelinew.c --- a/src/dmtimelinew.c Mon Jul 23 15:15:37 2018 +0300 +++ b/src/dmtimelinew.c Mon Aug 06 15:25:12 2018 +0300 @@ -7,7 +7,7 @@ #include "dmengine.h" -static BOOL dmSaveFloatValue(DMResource *res, DMFloat val) +static BOOL dmSaveFloatValue(DMResource *res, const DMFloat val) { char tmp[DT_FLOAT_STORE_SIZE]; snprintf(tmp, DT_FLOAT_STORE_SIZE, "%f", val); @@ -15,7 +15,7 @@ } -static int dmSaveTimelinePoints(DMResource *res, DMTimelinePoints *points, int type) +static int dmSaveTimelinePoints(DMResource *res, const DMTimelinePoints *points, const int type) { int point; Uint32 npoints; @@ -73,7 +73,7 @@ } -static int dmSaveTimelineCurve(DMResource *res, DMTimelineCurve *curve) +static int dmSaveTimelineCurve(DMResource *res, const DMTimelineCurve *curve) { int err; @@ -87,13 +87,14 @@ } -static int dmSaveTimelineEventParam(DMResource *res, DMTimelineEventParam *param) +static int dmSaveTimelineEventParam(DMResource *res, const DMTimelineEventParam *param) { int err; DMFTimelineEventParam hdr; Uint16 len; strncpy(hdr.name, param->name, sizeof(hdr.name)); + hdr.name[sizeof(hdr.name) - 1] = 0; hdr.type = param->type; if (!dmf_write_str(res, hdr.name, sizeof(hdr.name)) || @@ -124,12 +125,14 @@ } -static int dmSaveTimelineEvent(DMResource *res, DMTimelineEvent *event) +static int dmSaveTimelineEvent(DMResource *res, const DMTimelineEvent *event) { int param, err; DMFTimelineEvent hdr; strncpy(hdr.effectName, event->effect->name, sizeof(hdr.effectName)); + hdr.effectName[sizeof(hdr.effectName) - 1] = 0; + hdr.start = event->start; hdr.duration = event->duration; hdr.nparams = event->nparams; @@ -150,12 +153,13 @@ } -static int dmSaveTimelineTrack(DMResource *res, DMTimelineTrack *track) +static int dmSaveTimelineTrack(DMResource *res, const DMTimelineTrack *track) { int event, err; DMFTimelineTrack hdr; strncpy(hdr.name, track->name, sizeof(hdr.name)); + hdr.name[sizeof(hdr.name) - 1] = 0; if (!dmf_write_le32(res, track->index) || !dmf_write_le32(res, track->layer) || @@ -177,13 +181,15 @@ } -int dmSaveTimeline(DMResource *res, DMTimeline *tl) +int dmSaveTimeline(DMResource *res, const DMTimeline *tl) { int track, err; DMFTimeline hdr; memcpy(&hdr.magic, DT_MAGIC_ID, sizeof(hdr.magic)); strncpy(hdr.name, tl->name, sizeof(hdr.name)); + hdr.name[sizeof(hdr.name) - 1] = 0; + hdr.ntracks = tl->ntracks; hdr.duration = tl->duration;