1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

r14003: Clarify code that lead to Coverity report #13.

Not a bug, but better to remove false positives.
Jeremy.
This commit is contained in:
Jeremy Allison 2006-03-08 01:18:18 +00:00 committed by Gerald (Jerry) Carter
parent 7c6e274cd5
commit f9a75d7654
2 changed files with 16 additions and 13 deletions

View File

@ -971,7 +971,7 @@ BOOL parse_lpq_entry(enum printing_types printing_type,char *line,
}
/* in the LPRNG case, we skip lines starting by a space.*/
if (line && !ret && (printing_type==PRINT_LPRNG) )
if (!ret && (printing_type==PRINT_LPRNG) )
{
if (line[0]==' ')
return ret;

View File

@ -193,21 +193,24 @@ static int generic_queue_get(const char *printer_name,
/* turn the lpq output into a series of job structures */
qcount = 0;
ZERO_STRUCTP(status);
if (numlines)
if (numlines) {
queue = SMB_MALLOC_ARRAY(print_queue_struct, numlines+1);
if (queue) {
memset(queue, '\0', sizeof(print_queue_struct)*(numlines+1));
for (i=0; i<numlines; i++) {
/* parse the line */
if (parse_lpq_entry(printing_type,qlines[i],
&queue[qcount],status,qcount==0)) {
qcount++;
}
}
if (!queue) {
file_lines_free(qlines);
*q = NULL;
return 0;
}
}
file_lines_free(qlines);
memset(queue, '\0', sizeof(print_queue_struct)*(numlines+1));
for (i=0; i<numlines; i++) {
/* parse the line */
if (parse_lpq_entry(printing_type,qlines[i],
&queue[qcount],status,qcount==0)) {
qcount++;
}
}
file_lines_free(qlines);
*q = queue;
return qcount;
}