[buddy] Fix several PVS-Studio warnings
For #192. * src/bddio.c, src/cppext.cxx, src/kernel.c: Fix printf formats, calls to new, and simplify one check in bdd_delref_nc().
This commit is contained in:
parent
41b47966b0
commit
63818a3e69
3 changed files with 12 additions and 11 deletions
|
|
@ -130,7 +130,7 @@ void bdd_fprintall(FILE *ofile)
|
|||
{
|
||||
if (LOW(n) != -1)
|
||||
{
|
||||
fprintf(ofile, "[%5d - %2d] ", n, bddnodes[n].refcou);
|
||||
fprintf(ofile, "[%5d - %2u] ", n, bddnodes[n].refcou);
|
||||
if (filehandler)
|
||||
filehandler(ofile, bddlevel2var[LEVEL(n)]);
|
||||
else
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <iomanip>
|
||||
#include <new>
|
||||
#include "kernel.h"
|
||||
#include "bvecx.h"
|
||||
|
||||
|
|
@ -190,7 +191,7 @@ ostream &operator<<(ostream &o, const bdd &r)
|
|||
return o;
|
||||
}
|
||||
|
||||
int *set = new int[bddvarnum];
|
||||
int *set = new (std::nothrow) int[bddvarnum];
|
||||
if (set == NULL)
|
||||
{
|
||||
bdd_error(BDD_MEMORY);
|
||||
|
|
@ -252,7 +253,7 @@ ostream &operator<<(ostream &o, const bdd &r)
|
|||
return o;
|
||||
}
|
||||
|
||||
int *set = new int[bddvarnum];
|
||||
int *set = new (std::nothrow) int[bddvarnum];
|
||||
if (set == NULL)
|
||||
{
|
||||
bdd_error(BDD_MEMORY);
|
||||
|
|
|
|||
|
|
@ -774,19 +774,19 @@ void bdd_fprintstat(FILE *ofile)
|
|||
fprintf(ofile, "\nCache statistics\n");
|
||||
fprintf(ofile, "----------------\n");
|
||||
|
||||
fprintf(ofile, "Unique Access: %ld\n", s.uniqueAccess);
|
||||
fprintf(ofile, "Unique Chain: %ld\n", s.uniqueChain);
|
||||
fprintf(ofile, "Unique Hit: %ld\n", s.uniqueHit);
|
||||
fprintf(ofile, "Unique Miss: %ld\n", s.uniqueMiss);
|
||||
fprintf(ofile, "Unique Access: %lu\n", s.uniqueAccess);
|
||||
fprintf(ofile, "Unique Chain: %lu\n", s.uniqueChain);
|
||||
fprintf(ofile, "Unique Hit: %lu\n", s.uniqueHit);
|
||||
fprintf(ofile, "Unique Miss: %lu\n", s.uniqueMiss);
|
||||
fprintf(ofile, "=> Hit rate = %.2f\n",
|
||||
(s.uniqueHit+s.uniqueMiss > 0) ?
|
||||
((float)s.uniqueHit)/((float)s.uniqueHit+s.uniqueMiss) : 0);
|
||||
fprintf(ofile, "Operator Hits: %ld\n", s.opHit);
|
||||
fprintf(ofile, "Operator Miss: %ld\n", s.opMiss);
|
||||
fprintf(ofile, "Operator Hits: %lu\n", s.opHit);
|
||||
fprintf(ofile, "Operator Miss: %lu\n", s.opMiss);
|
||||
fprintf(ofile, "=> Hit rate = %.2f\n",
|
||||
(s.opHit+s.opMiss > 0) ?
|
||||
((float)s.opHit)/((float)s.opHit+s.opMiss) : 0);
|
||||
fprintf(ofile, "Swap count = %ld\n", s.swapCount);
|
||||
fprintf(ofile, "Swap count = %lu\n", s.swapCount);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1164,7 +1164,7 @@ BDD bdd_addref(BDD root)
|
|||
BDD bdd_delref_nc(BDD root)
|
||||
{
|
||||
#ifndef NDEBUG
|
||||
if (root < 2 || !bddrunning)
|
||||
if (!bddrunning)
|
||||
return root;
|
||||
if (root >= bddnodesize)
|
||||
return bdd_error(BDD_ILLBDD);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue