Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
7182-snmp-Types-and-specs-for-snmp_generic-vari...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 7182-snmp-Types-and-specs-for-snmp_generic-variable_get-1.patch of Package erlang
From 04472790f88afad73d81749bcfcdc2e42be60a5f Mon Sep 17 00:00:00 2001 From: Micael Karlberg <bmk@erlang.org> Date: Mon, 15 Jan 2024 09:36:52 +0100 Subject: [PATCH 42/67] [snmp] Types and specs for snmp_generic:variable_get/1 --- lib/snmp/doc/src/snmp_generic.xml | 16 ++++----- lib/snmp/src/agent/snmp_generic.erl | 52 ++++++++++++++++------------- 2 files changed, 35 insertions(+), 33 deletions(-) diff --git a/lib/snmp/doc/src/snmp_generic.xml b/lib/snmp/doc/src/snmp_generic.xml index a5440a4521..0b1552463b 100644 --- a/lib/snmp/doc/src/snmp_generic.xml +++ b/lib/snmp/doc/src/snmp_generic.xml @@ -489,6 +489,7 @@ value() = term() <marker id="variable_func"></marker> <marker id="variable_func2"></marker> + <marker id="variable_func21"></marker> </desc> </func> @@ -505,7 +506,7 @@ value() = term() <p>The function returns according to the specification of an instrumentation function. </p> - <marker id="variable_func3"></marker> + <marker id="variable_func22"></marker> </desc> </func> @@ -521,7 +522,7 @@ value() = term() <p>The function returns according to the specification of an instrumentation function. </p> - <marker id="variable_func3"></marker> + <marker id="variable_func23"></marker> </desc> </func> @@ -535,6 +536,7 @@ value() = term() instrumentation function. </p> <marker id="variable_func3"></marker> + <marker id="variable_func31"></marker> </desc> </func> @@ -547,7 +549,7 @@ value() = term() <p>The function returns according to the specification of an instrumentation function. </p> - <marker id="variable_get"></marker> + <marker id="variable_func32"></marker> </desc> </func> @@ -560,7 +562,7 @@ value() = term() <p>The function returns according to the specification of an instrumentation function. </p> - <marker id="variable_get"></marker> + <marker id="variable_func33"></marker> </desc> </func> @@ -578,12 +580,8 @@ value() = term() </func> <func> - <name since="">variable_get(NameDb) -> {value, Value} | undefined</name> + <name name="variable_get" arity="1" clause_i="1" since=""/> <fsummary>Get the value of a variable</fsummary> - <type> - <v>NameDb = name_db()</v> - <v>Value = value()</v> - </type> <desc> <p>Gets the value of a variable.</p> diff --git a/lib/snmp/src/agent/snmp_generic.erl b/lib/snmp/src/agent/snmp_generic.erl index bb85cd5094..433231d8fc 100644 --- a/lib/snmp/src/agent/snmp_generic.erl +++ b/lib/snmp/src/agent/snmp_generic.erl @@ -64,7 +64,6 @@ first_own_index. - %%%----------------------------------------------------------------- %%% Generic functions for implementing software tables %%% and variables. @@ -74,6 +73,11 @@ %%------------------------------------------------------------------ %% Access functions to the database. %%------------------------------------------------------------------ + +-spec variable_get(Name) -> {value, Value} | undefined when + Name :: snmpa:name() | snmpa:name_db(), + Value :: term(). + variable_get({Name, mnesia}) -> snmp_generic_mnesia:variable_get(Name); variable_get(NameDb) -> % ret {value, Val} | undefined @@ -178,56 +182,56 @@ table_max_col(NameDb, Col) -> % ret largest element in Col %% This is the default function for variables. %%------------------------------------------------------------------ --spec variable_func(Op :: new, NameDb) -> Result when - NameDb :: snmpa:name_db(), +-spec variable_func(Op :: new, Name) -> Result when + Name :: snmpa:name() | snmpa:name_db(), Result :: ok | boolean(); - (Op :: delete, NameDb) -> Result when - NameDb :: snmpa:name_db(), + (Op :: delete, Name) -> Result when + Name :: snmpa:name() | snmpa:name_db(), Result :: ok; - (Op :: get, NameDb) -> Result when - NameDb :: snmpa:name_db(), + (Op :: get, Name) -> Result when + Name :: snmpa:name() | snmpa:name_db(), Result :: {value, Value} | genErr, Value :: term(). -variable_func(new, NameDb) -> - case variable_get(NameDb) of +variable_func(new, Name) -> + case variable_get(Name) of {value, _} -> ok; undefined -> - #variable_info{defval = Defval} = variable_info(NameDb), - variable_set(NameDb, Defval) + #variable_info{defval = Defval} = variable_info(Name), + variable_set(Name, Defval) end; -variable_func(delete, _NameDb) -> +variable_func(delete, _Name) -> ok; -variable_func(get, NameDb) -> - case variable_get(NameDb) of +variable_func(get, Name) -> + case variable_get(Name) of {value, Val} -> {value, Val}; _ -> genErr end. --spec variable_func(Op :: is_set_ok, Value, NameDb) -> Result when +-spec variable_func(Op :: is_set_ok, Value, Name) -> Result when Value :: term(), - NameDb :: snmpa:name_db(), + Name :: snmpa:name() | snmpa:name_db(), Result :: noError; - (Op :: set, Value, NameDb) -> Result when + (Op :: set, Value, Name) -> Result when Value :: term(), - NameDb :: snmpa:name_db(), + Name :: snmpa:name() | snmpa:name_db(), Result :: noError | commitFailed; - (Op :: undo, Value, NameDb) -> Result when + (Op :: undo, Value, Name) -> Result when Value :: term(), - NameDb :: snmpa:name_db(), + Name :: snmpa:name() | snmpa:name_db(), Result :: noError. -variable_func(is_set_ok, _Val, _NameDb) -> +variable_func(is_set_ok, _Val, _Name) -> noError; -variable_func(set, Val, NameDb) -> - case variable_set(NameDb, Val) of +variable_func(set, Val, Name) -> + case variable_set(Name, Val) of true -> noError; false -> commitFailed end; -variable_func(undo, _Val, _NameDb) -> +variable_func(undo, _Val, _Name) -> noError. -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor