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:
Cary R 2008-05-15 10:36:43 -07:00 committed by Stephen Williams
parent ca880c73fc
commit 72b4256872
1 changed files with 8 additions and 2 deletions

View File

@ -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);