summaryrefslogtreecommitdiff
path: root/src/ptp-pack.c
diff options
context:
space:
mode:
authorLinus Walleij <triad@df.lth.se>2006-05-05 08:19:40 +0000
committerLinus Walleij <triad@df.lth.se>2006-05-05 08:19:40 +0000
commit6fc8103fee305460e632bf46091a43f7cccf783f (patch)
tree398604a2140b714fa4856becdae1cbb9859ef661 /src/ptp-pack.c
parentef5cca9f92587edef41b70a28e0a5612a9703917 (diff)
downloadlibmtp-6fc8103fee305460e632bf46091a43f7cccf783f.tar.gz
Upstream sync, more devices.
Diffstat (limited to 'src/ptp-pack.c')
-rw-r--r--src/ptp-pack.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/ptp-pack.c b/src/ptp-pack.c
index 27f512b..d76d9b3 100644
--- a/src/ptp-pack.c
+++ b/src/ptp-pack.c
@@ -501,18 +501,15 @@ ptp_unpack_DPV (
break;
}
case PTP_DTC_UNISTR: {
- /* this length includes the null character */
- const int unicsize = sizeof(uint16_t);
uint8_t len=dtoh8a(&data[0]);
if (len==0) {
- value->unistr = malloc(unicsize);
+ value->unistr = malloc(sizeof(value->unistr[0]));
value->unistr[0]=0;
} else {
int i;
- value->unistr = malloc(len*unicsize);
- for (i=0;i<len;i++) {
- value->unistr[i]=dtoh16a(&data[i*unicsize+1]);
- }
+ value->unistr = malloc(len*sizeof(value->unistr[0]));
+ for (i=0;i<len;i++)
+ value->unistr[i]=dtoh16a(&data[i*sizeof(value->unistr[0])+1]);
/* just to be sure... */
value->unistr[len-1]=0;
}
@@ -764,7 +761,7 @@ ptp_pack_DPV (PTPParams *params, PTPPropertyValue* value, unsigned char** dpvptr
case PTP_DTC_UNISTR: {
uint8_t len = 0;
/* note PTP_MAXSTRLEN includes the null terminator */
- while (((uint16_t *)value->unistr)[len] != 0 && len != PTP_MAXSTRLEN-1)
+ while (value->unistr[len] != 0 && len != PTP_MAXSTRLEN-1)
len++;
if (len==0) {
size=1;
@@ -777,7 +774,7 @@ ptp_pack_DPV (PTPParams *params, PTPPropertyValue* value, unsigned char** dpvptr
memset(dpv,0,size);
htod8a(&dpv[0],len+1);
for (i = 0; i < len; i++)
- htod16a(&dpv[i*2+1],((uint16_t *)value->unistr)[i]);
+ htod16a(&dpv[i*2+1],value->unistr[i]);
/* terminator is done by memset above */
}