Hello, In many driver files, nut-scanner files and parseconf.c file, memory allocation functions malloc(), calloc() and realloc() is used. Can we replace those calls with xmalloc(), xcalloc() and xrealloc() so that it will report and log error if it occurs during memory allocation? Attached file shows listing of files where malloc, calloc and realloc function calls are used. Thanks & Regards, Prachi Gandhi Eaton India Engineering Center (EIEC) Kharadi, Pune. Tel : 91-20-6633 7432 email: [email protected] URL: www.eaton.com <file:///C:/Documents%20and%20Settings/e5251237/Application%20Data/Micro soft/Signatures/www.eaton.com>
FileName | Line# | Code ------------------------------------------------------------------------------------------------------------------------ /Prachi/working/trunk/drivers/libhid.c | 95 | rbuf = calloc(1, sizeof(*rbuf));
/Prachi/working/trunk/drivers/libhid.c | 119 | rbuf->data[id] = calloc(rbuf->len[id], sizeof(*(rbuf->data[id]))); /Prachi/working/trunk/drivers/hidparser.c | 555 | pDesc = calloc(1, sizeof(*pDesc)); /Prachi/working/trunk/drivers/hidparser.c | 560 | pDesc->item = calloc(MAX_REPORT, sizeof(*pDesc->item)); /Prachi/working/trunk/drivers/hidparser.c | 566 | parser = calloc(1, sizeof(*parser)); /Prachi/working/trunk/drivers/hidparser.c | 604 | pDesc->item = realloc(pDesc->item, pDesc->nitems * sizeof(*pDesc->item)); /Prachi/working/trunk/drivers/solis.c | 801 | tmt = ( time_t * ) malloc( sizeof( time_t ) ); /Prachi/working/trunk/drivers/solis.c | 965 | tmt = ( time_t * ) malloc( sizeof( time_t ) ); /Prachi/working/trunk/drivers/usb-common.c | 118 | m = malloc(sizeof(*m)); /Prachi/working/trunk/drivers/usb-common.c | 123 | data = calloc(1, sizeof(*data)); /Prachi/working/trunk/drivers/usb-common.c | 187 | preg = malloc(sizeof(*preg)); /Prachi/working/trunk/drivers/usb-common.c | 333 | m = malloc(sizeof(*m)); /Prachi/working/trunk/drivers/usb-common.c | 338 | data = calloc(1, sizeof(*data)); /Prachi/working/trunk/drivers/rhino.c | 554 | tmt = ( time_t * ) malloc( sizeof( time_t ) ); /Prachi/working/trunk/drivers/rhino.c | 653 | tmt = ( time_t * ) malloc( sizeof( time_t ) ); /Prachi/working/trunk/tools/nut-scanner/scan_snmp.c | 81 | buf = malloc( response->variables->val_len + 1 ); /Prachi/working/trunk/tools/nut-scanner/scan_snmp.c | 118 | buf = malloc( session->community_len + 1 ); /Prachi/working/trunk/tools/nut-scanner/scan_snmp.c | 489 | tmp_sec = malloc(sizeof(nutscan_snmp_t)); /Prachi/working/trunk/tools/nut-scanner/scan_nut.c | 49 | UPSCONN_t *ups = malloc(sizeof(*ups)); /Prachi/working/trunk/tools/nut-scanner/scan_nut.c | 94 | dev->port = malloc(buf_size); /Prachi/working/trunk/tools/nut-scanner/nutscan-device.c | 27 | device = malloc(sizeof(nutscan_device_t)); /Prachi/working/trunk/tools/nut-scanner/nutscan-device.c | 112 | opt->next = malloc(sizeof(nutscan_options_t)); /Prachi/working/trunk/tools/nut-scanner/scan_avahi.c | 99 | dev->port=malloc(buf_size); /Prachi/working/trunk/tools/nut-scanner/scan_avahi.c | 108 | dev->port=malloc(buf_size); /Prachi/working/trunk/tools/nut-scanner/scan_avahi.c | 150 | dev->port=malloc(buf_size); /Prachi/working/trunk/common/parseconf.c | 152 | ctx->arglist[argpos] = realloc(ctx->arglist[argpos], newlen); /Prachi/working/trunk/common/parseconf.c | 186 | ctx->wordbuf = realloc(ctx->wordbuf, ctx->wordbufsize); /Prachi/working/trunk/common/parseconf.c | 386 | ctx->wordbuf = calloc(1, ctx->wordbufsize); ------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------------------------ Code Conformance Summary: Invalid "memory" count : 28 Invalid "comment" count : 0 Invalid "goto" count : 0 Invalid "printf" count : 0 Invalid "syslog" count : 0 Invalid "time" count : 0 Invalid "shebang" count : 0 Total Invalid log count : 28
_______________________________________________ Nut-upsdev mailing list [email protected] http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/nut-upsdev
