From: Vlad Apostolov Date: Wed, 8 Aug 2007 07:54:05 +0000 (+0000) Subject: pv 968773, author Chris Pascoe , rv vapo - minor fixes for... X-Git-Tag: v1.1.0~464 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1150f6c3ba73dfb5f54e8df96ee8a816d60a00cd;p=xfstests-dev.git pv 968773, author Chris Pascoe , rv vapo - minor fixes for XFS DMAPI tests Merge of master-melb:xfs-cmds:29348a by kenmcd. pv 968773, author Chris Pascoe , rv vapo - minor fixes for XFS DMAPI tests --- diff --git a/dmapi/src/common/lib/util.c b/dmapi/src/common/lib/util.c index 0160b384..958b7e45 100644 --- a/dmapi/src/common/lib/util.c +++ b/dmapi/src/common/lib/util.c @@ -311,11 +311,11 @@ setup_dmapi(dm_sessid_t *sidp) char *cp; if (dm_init_service(&cp) == -1) { - err_msg("%s/%d: Can't init dmapi", __FILE__, __LINE__); + err_msg("%s/%d: Can't init dmapi\n", __FILE__, __LINE__); return(1); } if (strcmp(cp, DM_VER_STR_CONTENTS)) { - err_msg("%s/%d: Compiled for a different version", __FILE__, __LINE__); + err_msg("%s/%d: Compiled for a different version\n", __FILE__, __LINE__); return(1); } @@ -372,7 +372,7 @@ save_filedata( retval = 0; filebuf = malloc(CHUNKSIZE); if (filebuf == NULL) { - err_msg("%s/%d: Can't alloc memory for file buffer", __FILE__, __LINE__); + err_msg("%s/%d: Can't alloc memory for file buffer\n", __FILE__, __LINE__); goto out; } @@ -476,7 +476,7 @@ restore_filedata( filebuf = malloc(CHUNKSIZE); if (filebuf == NULL) { - err_msg("%s/%d: Can't alloc memory for file buffer", __FILE__, __LINE__); + err_msg("%s/%d: Can't alloc memory for file buffer\n", __FILE__, __LINE__); goto out; } diff --git a/dmapi/src/simple/dm_getall_tokens.c b/dmapi/src/simple/dm_getall_tokens.c index bb15b7e8..2df4f018 100644 --- a/dmapi/src/simple/dm_getall_tokens.c +++ b/dmapi/src/simple/dm_getall_tokens.c @@ -73,7 +73,7 @@ main( int argc, char **argv ) printf("tokens=\""); for( i = 0; i < rnelem; i++ ){ - printf("%d ", (int)(tokenbuf+i)); + printf("%d ", (int)*(tokenbuf+i)); } printf("\"\n"); exit(0); diff --git a/dmapi/src/suite1/cmd/print_event.c b/dmapi/src/suite1/cmd/print_event.c index c926e05f..9a4beba9 100644 --- a/dmapi/src/suite1/cmd/print_event.c +++ b/dmapi/src/suite1/cmd/print_event.c @@ -1151,7 +1151,7 @@ finish_responding( { int error = 0; u_int nbytes, ntokens = 0, ret_ntokens, i; - dm_token_t *tokenbuf = NULL; + dm_token_t *tokenbuf = NULL, *tokenptr; size_t buflen, ret_buflen; char *msgbuf = NULL; dm_eventmsg_t *msg; @@ -1173,14 +1173,16 @@ finish_responding( * If we're already using the returned size, double it and try again. */ do { + dm_token_t *tmpbuf; ntokens = (ntokens != ret_ntokens) ? ret_ntokens : ntokens*2; nbytes = ntokens * (sizeof(dm_token_t) + sizeof(dm_vardata_t)); - tokenbuf = malloc(nbytes); - if (tokenbuf == NULL) { + tmpbuf = realloc(tokenbuf, nbytes); + if (tmpbuf == NULL) { err_msg("Can't malloc %d bytes for tokenbuf\n", nbytes); error = 1; goto out; } + tokenbuf = tmpbuf; error = dm_getall_tokens(sid, ntokens, tokenbuf, &ret_ntokens); } while (error && errno == E2BIG); @@ -1189,25 +1191,28 @@ finish_responding( goto out; } + tokenptr = tokenbuf; for (i = 0; i < ret_ntokens; i++) { if (Verbose) - err_msg("Responding to outstanding event for token %d\n",(int)*tokenbuf); + err_msg("Responding to outstanding event for token %d\n",(int)*tokenptr); /* * The E2BIG dance reprise... */ do { + char *tmpbuf; buflen = (buflen != ret_buflen) ? ret_buflen : buflen * 2; - msgbuf = malloc(buflen); - if (msgbuf == NULL) { + tmpbuf = realloc(msgbuf, buflen); + if (tmpbuf == NULL) { err_msg("Can't malloc %d bytes for msgbuf\n", buflen); error = 1; goto out; } - error = dm_find_eventmsg(sid, *tokenbuf, buflen, msgbuf, &ret_buflen); + msgbuf = tmpbuf; + error = dm_find_eventmsg(sid, *tokenptr, buflen, msgbuf, &ret_buflen); } while (error && errno == E2BIG); if (error) { - errno_msg("Can't find the event message for token %d", (int)*tokenbuf); + errno_msg("Can't find the event message for token %d", (int)*tokenptr); goto out; } @@ -1219,7 +1224,7 @@ finish_responding( msg = DM_STEP_TO_NEXT(msg, dm_eventmsg_t *); } - tokenbuf++; + tokenptr++; } out: diff --git a/dmapi/src/suite2/src/dm_test_daemon.c b/dmapi/src/suite2/src/dm_test_daemon.c index e47cad2a..214750aa 100644 --- a/dmapi/src/suite2/src/dm_test_daemon.c +++ b/dmapi/src/suite2/src/dm_test_daemon.c @@ -1171,7 +1171,7 @@ finish_responding( { int error = 0; u_int nbytes, ntokens = 0, ret_ntokens, i; - dm_token_t *tokenbuf = NULL; + dm_token_t *tokenbuf = NULL, *tokenptr; size_t buflen, ret_buflen; char *msgbuf = NULL; dm_eventmsg_t *msg; @@ -1193,14 +1193,16 @@ finish_responding( * If we're already using the returned size, double it and try again. */ do { + dm_token_t *tmpbuf; ntokens = (ntokens != ret_ntokens) ? ret_ntokens : ntokens*2; nbytes = ntokens * (sizeof(dm_token_t) + sizeof(dm_vardata_t)); - tokenbuf = malloc(nbytes); - if (tokenbuf == NULL) { + tmpbuf = realloc(tokenbuf, nbytes); + if (tmpbuf == NULL) { err_msg("Can't malloc %d bytes for tokenbuf\n", nbytes); error = 1; goto out; } + tokenbuf = tmpbuf; error = dm_getall_tokens(sid, ntokens, tokenbuf, &ret_ntokens); } while (error && errno == E2BIG); @@ -1209,25 +1211,28 @@ finish_responding( goto out; } + tokenptr = tokenbuf; for (i = 0; i < ret_ntokens; i++) { if (Verbose) - err_msg("Responding to outstanding event for token %d\n",(int)*tokenbuf); + err_msg("Responding to outstanding event for token %d\n",(int)*tokenptr); /* * The E2BIG dance reprise... */ do { + char *tmpbuf; buflen = (buflen != ret_buflen) ? ret_buflen : buflen * 2; - msgbuf = malloc(buflen); - if (msgbuf == NULL) { + tmpbuf = realloc(msgbuf, buflen); + if (tmpbuf == NULL) { err_msg("Can't malloc %d bytes for msgbuf\n", buflen); error = 1; goto out; } - error = dm_find_eventmsg(sid, *tokenbuf, buflen, msgbuf, &ret_buflen); + msgbuf = tmpbuf; + error = dm_find_eventmsg(sid, *tokenptr, buflen, msgbuf, &ret_buflen); } while (error && errno == E2BIG); if (error) { - errno_msg("Can't find the event message for token %d", (int)*tokenbuf); + errno_msg("Can't find the event message for token %d", (int)*tokenptr); goto out; } @@ -1239,7 +1244,7 @@ finish_responding( msg = DM_STEP_TO_NEXT(msg, dm_eventmsg_t *); } - tokenbuf++; + tokenptr++; } out: