Skip to content

Commit

Permalink
more replace sprintf(buf) + strdup(buf) pattern with new aprintf()
Browse files Browse the repository at this point in the history
Overlooked one file during recent commit.
  • Loading branch information
axxel committed Sep 13, 2024
1 parent e68b3ea commit 4e0417a
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions libgphoto2_port/vusb/vcamera.c
Original file line number Diff line number Diff line change
Expand Up @@ -1746,16 +1746,14 @@ static int
ptp_datetime_getdesc (vcamera* cam, PTPDevicePropDesc *desc) {
struct tm *tm;
time_t xtime;
char xdate[40];

desc->DevicePropertyCode = 0x5011;
desc->DataType = 0xffff; /* string */
desc->GetSet = 1; /* get only */
time(&xtime);
tm = gmtime(&xtime);
sprintf(xdate,"%04d%02d%02dT%02d%02d%02d",tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec);
desc->FactoryDefaultValue.str = strdup (xdate);
desc->CurrentValue.str = strdup (xdate);
desc->FactoryDefaultValue.str = aprintf("%04d%02d%02dT%02d%02d%02d",tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec);
desc->CurrentValue.str = strdup (desc->FactoryDefaultValue.str);
desc->FormFlag = 0; /* no form */
/*ptp_inject_interrupt (cam, 1000, 0x4006, 1, 0x5011, 0xffffffff);*/
return 1;
Expand All @@ -1765,12 +1763,10 @@ static int
ptp_datetime_getvalue (vcamera* cam, PTPPropertyValue *val) {
struct tm *tm;
time_t xtime;
char xdate[40];

time(&xtime);
tm = gmtime(&xtime);
sprintf(xdate,"%04d%02d%02dT%02d%02d%02d",tm->tm_year+1900,tm->tm_mon+1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec);
val->str = strdup (xdate);
val->str = aprintf("%04d%02d%02dT%02d%02d%02d",tm->tm_year + 1900,tm->tm_mon + 1,tm->tm_mday,tm->tm_hour,tm->tm_min,tm->tm_sec);
/*ptp_inject_interrupt (cam, 1000, 0x4006, 1, 0x5011, 0xffffffff);*/
return 1;
}
Expand Down

0 comments on commit 4e0417a

Please sign in to comment.