Return 0 when vpi_handle_by_name() is called with an unsupported object.
vpi_handle_by_name() was assuming it was always given a valid scope object. In the context of vpi_chk_error() this is not required and some users use/abuse the interface by calling the function with invalid objects expecting a 0 return value. This patch adds an explicit check for the supported types vpiScope and as an extension vpiModule. Anything else should be flagged as an error once we have vpi_chk_error() implemented, but for now it just returns 0.
This commit is contained in:
parent
ca880c73fc
commit
72b4256872
|
|
@ -863,10 +863,16 @@ vpiHandle vpi_handle_by_name(const char *name, vpiHandle scope)
|
|||
*/
|
||||
if (scope) {
|
||||
/* Some implementations support either a module or a scope. */
|
||||
if (vpi_get(vpiType, scope ) == vpiScope) {
|
||||
switch (vpi_get(vpiType, scope)) {
|
||||
case vpiScope:
|
||||
hand = vpi_handle(vpiModule, scope);
|
||||
} else {
|
||||
break;
|
||||
case vpiModule:
|
||||
hand = scope;
|
||||
break;
|
||||
default:
|
||||
// Use vpi_chk_error() here when it is implemented.
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
hand = find_scope(name, NULL, 0);
|
||||
|
|
|
|||
Loading…
Reference in New Issue