Skip to content

Commit c567147

Browse files
committed
testsuite: explicitly cast or redeclare to compatible data types in afpclient
1 parent 35f5a55 commit c567147

File tree

1 file changed

+46
-44
lines changed

1 file changed

+46
-44
lines changed

test/testsuite/afpclient.c

Lines changed: 46 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,8 @@ int my_dsi_stream_send(DSI *dsi, void *buf, size_t length)
203203

204204
if (!length) { /* just write the header */
205205
length = (my_dsi_stream_write(dsi, block, sizeof(block)) == sizeof(block));
206-
return length; /* really 0 on failure, 1 on success */
206+
/* really 0 on failure, 1 on success */
207+
return (int) length;
207208
}
208209

209210
if (use_writev) {
@@ -343,12 +344,12 @@ static void SendInit(DSI *dsi)
343344
static void SetLen(DSI *dsi, int ofs)
344345
{
345346
dsi->datalen = ofs;
346-
dsi->header.dsi_len = htonl(dsi->datalen);
347+
dsi->header.dsi_len = htonl((uint32_t) dsi->datalen);
347348
dsi->header.dsi_code = 0;
348349
}
349350

350351
/* ------------------------------- */
351-
static int SendCmd(DSI *dsi, int cmd)
352+
static int SendCmd(DSI *dsi, uint8_t cmd)
352353
{
353354
int ofs;
354355
SendInit(dsi);
@@ -359,7 +360,7 @@ static int SendCmd(DSI *dsi, int cmd)
359360
}
360361

361362
/* ------------------------------- */
362-
static int SendCmdWithU16(DSI *dsi, int cmd, uint16_t param)
363+
static int SendCmdWithU16(DSI *dsi, uint8_t cmd, uint16_t param)
363364
{
364365
int ofs;
365366
SendInit(dsi);
@@ -373,7 +374,7 @@ static int SendCmdWithU16(DSI *dsi, int cmd, uint16_t param)
373374
}
374375

375376
/* ------------------------- */
376-
static unsigned int SendCmdVolDidCname(CONN *conn, int cmd, uint16_t vol,
377+
static unsigned int SendCmdVolDidCname(CONN *conn, uint8_t cmd, uint16_t vol,
377378
int did, char *name)
378379
{
379380
int ofs;
@@ -488,21 +489,21 @@ unsigned int AFPopenLogin(CONN *conn, char *vers, char *uam, char *usr,
488489
SendInit(dsi);
489490
ofs = 0;
490491
dsi->commands[ofs++] = AFP_LOGIN;
491-
len = strlen(vers);
492+
len = (uint8_t) strlen(vers);
492493
dsi->commands[ofs++] = len;
493494
memcpy(&dsi->commands[ofs], vers, len);
494495
ofs += len;
495-
len = strlen(uam);
496+
len = (uint8_t) strlen(uam);
496497
dsi->commands[ofs++] = len;
497498
memcpy(&dsi->commands[ofs], uam, len);
498499
ofs += len;
499-
len = strlen(usr);
500+
len = (uint8_t) strlen(usr);
500501

501502
if (len) {
502503
dsi->commands[ofs++] = len;
503504
memcpy(&dsi->commands[ofs], usr, len);
504505
ofs += len;
505-
len = strlen(pwd);
506+
len = (uint8_t) strlen(pwd);
506507

507508
if (ofs & 1) {
508509
dsi->commands[ofs++] = 0;
@@ -542,15 +543,15 @@ unsigned int AFPopenLoginExt(CONN *conn, char *vers, char *uam, char *usr,
542543
temp16 = 0; /* flag */
543544
memcpy(&dsi->commands[ofs], &temp16, sizeof(temp16));
544545
ofs += sizeof(temp16);
545-
len = strlen(vers);
546+
len = (uint8_t) strlen(vers);
546547
dsi->commands[ofs++] = len;
547548
memcpy(&dsi->commands[ofs], vers, len);
548549
ofs += len;
549-
len = strlen(uam);
550+
len = (uint8_t) strlen(uam);
550551
dsi->commands[ofs++] = len;
551552
memcpy(&dsi->commands[ofs], uam, len);
552553
ofs += len;
553-
len16 = strlen(usr);
554+
len16 = (uint16_t) strlen(usr);
554555
/* user name */
555556
dsi->commands[ofs++] = 3;
556557
temp16 = htons(len16);
@@ -578,7 +579,7 @@ unsigned int AFPopenLoginExt(CONN *conn, char *vers, char *uam, char *usr,
578579

579580
/* HACK */
580581
if (len16) {
581-
len = strlen(pwd);
582+
len = (uint8_t) strlen(pwd);
582583
memcpy(&dsi->commands[ofs], pwd, len);
583584
ofs += PASSWDLEN;
584585
}
@@ -602,7 +603,7 @@ unsigned int AFPChangePW(CONN *conn, char *uam, char *usr, char *opwd,
602603
ofs = 0;
603604
dsi->commands[ofs++] = AFP_CHANGEPW;
604605
dsi->commands[ofs++] = 0;
605-
len = strlen(uam);
606+
len = (uint8_t) strlen(uam);
606607
dsi->commands[ofs++] = len;
607608
memcpy(&dsi->commands[ofs], uam, len);
608609
ofs += len;
@@ -611,21 +612,21 @@ unsigned int AFPChangePW(CONN *conn, char *uam, char *usr, char *opwd,
611612
dsi->commands[ofs++] = 0;
612613
}
613614

614-
len = strlen(usr);
615+
len = (uint8_t) strlen(usr);
615616

616617
if (len) {
617618
dsi->commands[ofs++] = len;
618619
memcpy(&dsi->commands[ofs], usr, len);
619620
ofs += len;
620-
len = strlen(opwd);
621+
len = (uint8_t) strlen(opwd);
621622

622623
if (ofs & 1) {
623624
dsi->commands[ofs++] = 0;
624625
}
625626

626627
memcpy(&dsi->commands[ofs], opwd, len);
627628
ofs += PASSWDLEN;
628-
len = strlen(pwd);
629+
len = (uint8_t) strlen(pwd);
629630
memcpy(&dsi->commands[ofs], pwd, len);
630631
ofs += PASSWDLEN;
631632
}
@@ -799,7 +800,7 @@ static int set_off_t(off_t offset, uint8_t *rbuf, int is64)
799800
offset &= 0xffffffff;
800801
}
801802

802-
temp = htonl(offset);
803+
temp = htonl((uint32_t) offset);
803804
memcpy(rbuf, &temp, sizeof(temp));
804805
ret += sizeof(temp);
805806
return ret;
@@ -876,7 +877,7 @@ uint16_t AFPOpenVol(CONN *conn, char *vol, uint16_t bitmap)
876877
{
877878
int ofs;
878879
uint16_t result, volID = 0;
879-
int len;
880+
uint8_t len;
880881
DSI *dsi;
881882
dsi = &conn->dsi;
882883
SendInit(dsi);
@@ -886,7 +887,7 @@ uint16_t AFPOpenVol(CONN *conn, char *vol, uint16_t bitmap)
886887
bitmap = htons(bitmap);
887888
memcpy(dsi->commands + ofs, &bitmap, sizeof(bitmap));
888889
ofs += 2;
889-
len = strlen(vol);
890+
len = (uint8_t) strlen(vol);
890891
dsi->commands[ofs++] = len;
891892
memcpy(&dsi->commands[ofs], vol, len);
892893
ofs += len;
@@ -1141,7 +1142,7 @@ int afp_volume_pack(unsigned char *b, struct afp_volume_parms *parms,
11411142
void afp_filedir_unpack(struct afp_filedir_parms *filedir, unsigned char *b,
11421143
uint16_t rfbitmap, uint16_t rdbitmap)
11431144
{
1144-
char isdir;
1145+
int isdir;
11451146
uint16_t i, j;
11461147
uint32_t l;
11471148
int r;
@@ -1315,7 +1316,7 @@ void afp_filedir_unpack(struct afp_filedir_parms *filedir, unsigned char *b,
13151316
int afp_filedir_pack(unsigned char *b, struct afp_filedir_parms *filedir,
13161317
uint16_t rfbitmap, uint16_t rdbitmap)
13171318
{
1318-
char isdir;
1319+
int isdir;
13191320
uint16_t i, tp;
13201321
uint32_t l;
13211322
int bit = 0;
@@ -1442,8 +1443,8 @@ int afp_filedir_pack(unsigned char *b, struct afp_filedir_parms *filedir,
14421443
memcpy(l_ofs, &i, sizeof(i));
14431444

14441445
if (filedir->lname) {
1445-
i = strlen(filedir->lname);
1446-
*b = i;
1446+
i = (uint16_t) strlen(filedir->lname);
1447+
*b = (unsigned char) i;
14471448
b++;
14481449
memcpy(b, filedir->lname, i);
14491450
b += i;
@@ -1461,7 +1462,7 @@ int afp_filedir_pack(unsigned char *b, struct afp_filedir_parms *filedir,
14611462
b += sizeof(l);
14621463

14631464
if (filedir->utf8_name) {
1464-
i = strlen(filedir->utf8_name);
1465+
i = (uint16_t) strlen(filedir->utf8_name);
14651466
tp = htons(i);
14661467
memcpy(b, &tp, sizeof(tp));
14671468
b += sizeof(tp);
@@ -1559,16 +1560,16 @@ int FPset_name(CONN *conn, int ofs, char *name)
15591560
dsi->commands[ofs++] = 3; /* long name */
15601561
memcpy(&dsi->commands[ofs], &hint, sizeof(hint));
15611562
ofs += sizeof(hint);
1562-
len = strlen(name);
1563-
len16 = htons(len);
1563+
len = (int) strlen(name);
1564+
len16 = htons((uint16_t) len);
15641565
memcpy(&dsi->commands[ofs], &len16, sizeof(len16));
15651566
ofs += sizeof(len16);
15661567
u2mac(&dsi->commands[ofs], name, len);
15671568
ofs += len;
15681569
} else {
15691570
dsi->commands[ofs++] = 2; /* long name */
1570-
len = strlen(name);
1571-
dsi->commands[ofs++] = len;
1571+
len = (int) strlen(name);
1572+
dsi->commands[ofs++] = (uint8_t) len;
15721573
u2mac(&dsi->commands[ofs], name, len);
15731574
ofs += len;
15741575
}
@@ -1623,7 +1624,7 @@ unsigned int AFPWriteHeader(DSI *dsi, uint16_t fork, int offset, int size,
16231624
memcpy(dsi->commands + ofs, &rsize, sizeof(rsize));
16241625
ofs += sizeof(rsize);
16251626
dsi->datalen = ofs; /* 12*/
1626-
dsi->header.dsi_len = htonl(dsi->datalen + size);
1627+
dsi->header.dsi_len = htonl((uint32_t) dsi->datalen + size);
16271628
dsi->header.dsi_code = htonl(ofs);
16281629
my_dsi_stream_send(dsi, dsi->commands, ofs);
16291630
my_dsi_stream_write(dsi, data, size);
@@ -1803,7 +1804,7 @@ unsigned int AFPAddComment(CONN *conn, uint16_t vol, int did, char *name,
18031804
char *cmt)
18041805
{
18051806
int ofs;
1806-
int len;
1807+
uint8_t len;
18071808
DSI *dsi;
18081809
dsi = &conn->dsi;
18091810
SendInit(dsi);
@@ -1820,7 +1821,7 @@ unsigned int AFPAddComment(CONN *conn, uint16_t vol, int did, char *name,
18201821
ofs++;
18211822
}
18221823

1823-
len = strlen(cmt);
1824+
len = (uint8_t) strlen(cmt);
18241825
dsi->commands[ofs++] = len;
18251826
memcpy(dsi->commands + ofs, cmt, len);
18261827
ofs += len;
@@ -1836,7 +1837,7 @@ unsigned int AFPGetSessionToken(CONN *conn, int type, uint32_t time, int len,
18361837
char *token)
18371838
{
18381839
int ofs;
1839-
uint16_t tp = htons(type);
1840+
uint16_t tp = htons((uint16_t) type);
18401841
uint32_t temp;
18411842
DSI *dsi;
18421843
dsi = &conn->dsi;
@@ -1953,7 +1954,7 @@ unsigned int AFPMapName(CONN *conn, char fn, char *name)
19531954
dsi->commands[ofs++] = AFP_MAPNAME;
19541955
memcpy(dsi->commands + ofs, &fn, sizeof(fn));
19551956
ofs++;
1956-
len = strlen(name);
1957+
len = (uint16_t) strlen(name);
19571958

19581959
switch (fn) {
19591960
case 1:
@@ -1966,7 +1967,7 @@ unsigned int AFPMapName(CONN *conn, char fn, char *name)
19661967
case 3:
19671968
case 4:
19681969
default:
1969-
dsi->commands[ofs++] = len;
1970+
dsi->commands[ofs++] = (uint8_t) len;
19701971
break;
19711972
}
19721973

@@ -2303,11 +2304,12 @@ unsigned int AFPCatSearch(CONN *conn, uint16_t vol, uint32_t nbe, char *pos,
23032304
temp = htonl(rbitmap);
23042305
memcpy(dsi->commands + ofs, &temp, sizeof(temp));
23052306
ofs += sizeof(temp);
2306-
len = afp_filedir_pack(dsi->commands + ofs + 2, filedir, rbitmap & 0xffff, 0);
2307-
dsi->commands[ofs] = len;
2307+
len = afp_filedir_pack(dsi->commands + ofs + 2, filedir,
2308+
rbitmap & 0xffff, 0);
2309+
dsi->commands[ofs] = (uint8_t) len;
23082310
ofs += len + 2;
23092311
len = afp_filedir_pack(dsi->commands + ofs + 2, filedir2, rbitmap & 0xffff, 0);
2310-
dsi->commands[ofs] = len;
2312+
dsi->commands[ofs] = (uint8_t) len;
23112313
ofs += len + 2;
23122314
SetLen(dsi, ofs);
23132315
my_dsi_stream_send(dsi, dsi->commands, dsi->datalen);
@@ -2354,11 +2356,11 @@ unsigned int AFPCatSearchExt(CONN *conn, uint16_t vol, uint32_t nbe, char *pos,
23542356
memcpy(dsi->commands + ofs, &temp, sizeof(temp));
23552357
ofs += sizeof(temp);
23562358
len = afp_filedir_pack(dsi->commands + ofs + 2, filedir, rbitmap & 0xffff, 0);
2357-
i = htons(len);
2359+
i = htons((uint16_t) len);
23582360
memcpy(dsi->commands + ofs, &i, sizeof(i));
23592361
ofs += len + 2;
23602362
len = afp_filedir_pack(dsi->commands + ofs + 2, filedir2, rbitmap & 0xffff, 0);
2361-
i = htons(len);
2363+
i = htons((uint16_t) len);
23622364
memcpy(dsi->commands + ofs, &i, sizeof(i));
23632365
ofs += len + 2;
23642366
SetLen(dsi, ofs);
@@ -2436,7 +2438,7 @@ unsigned int AFPGetExtAttr(CONN *conn, uint16_t vol, int did, uint16_t bitmap,
24362438
ofs++;
24372439
}
24382440

2439-
len = strlen(attrname);
2441+
len = (uint16_t) strlen(attrname);
24402442
len = htons(len);
24412443
memcpy(dsi->commands + ofs, &len, sizeof(len));
24422444
ofs += sizeof(len);
@@ -2516,14 +2518,14 @@ unsigned int AFPSetExtAttr(CONN *conn, uint16_t vol, int did, uint16_t bitmap,
25162518
ofs++;
25172519
}
25182520

2519-
len = strlen(attrname);
2521+
len = (uint16_t) strlen(attrname);
25202522
len = htons(len);
25212523
memcpy(dsi->commands + ofs, &len, sizeof(len));
25222524
ofs += sizeof(len);
25232525
len = ntohs(len);
25242526
memcpy(&dsi->commands[ofs], attrname, len);
25252527
ofs += len;
2526-
datalen = strlen(data);
2528+
datalen = (uint32_t) strlen(data);
25272529
datalen = htonl(datalen);
25282530
memcpy(dsi->commands + ofs, &datalen, sizeof(datalen));
25292531
ofs += sizeof(datalen);
@@ -2562,7 +2564,7 @@ unsigned int AFPRemoveExtAttr(CONN *conn, uint16_t vol, int did,
25622564
ofs++;
25632565
}
25642566

2565-
len = strlen(attrname);
2567+
len = (uint16_t) strlen(attrname);
25662568
len = htons(len);
25672569
memcpy(dsi->commands + ofs, &len, sizeof(len));
25682570
ofs += sizeof(len);

0 commit comments

Comments
 (0)