Bugs in Erlang code -- a common one?

Ulf Wiger <>
Mon Mar 21 02:49:11 CET 2005


Den 2005-03-20 18:49:37 skrev Kostis Sagonas <>:

> For example, the code of snmp/src/compile/snmpc.erl at some point
> reads:
>
> -----------------------------------------------------------------------
> define_cols(...) ->
>     SIok = case SubIndex of
>                {Parent,[_SI]} when Parent =/= NameOfEntry ->
>                    snmpc_lib:print_error(
>                      "Invalid parent ~p for table column ~p (should be  
> ~p).",
>                      [Parent,NameOfCol,NameOfEntry],Oline),
>                    false;
>                {NameOfEntry,[SI]} when SI =/= SubIndex ->
>                    snmpc_lib:print_error(
>                      "Invalid column number ~p for column ~p.",
>                      [SI,NameOfCol],Oline),
>                    false;
>                {NameOfEntry,[SubIndex]} ->
>                    ok;
>     ....
> ------------------------------------------------------------------------
>
> and a moment's thought can reveal that there is something fishy here.

Maybe it's because it's 2:30 am (don't ask), but revealing the
fishiness required more than a moment's thought for
me.  (-:  I will resist the urge to try to investigate what
kind of code the compiler actually puts out.

However...

The clause you left out (in order to save space?)
contained something that at after a moment's thought
was a bit fishy too, but I will not fault Dialyzer for
missing it:

      _Q ->
         snmpc_lib:print_error(
	    "Invalid parent for column ~p.",[NameOfCol],Oline)
      end,

In consideration of others who may be reading this list in
the wee hours, I will save you the trouble of chasing the
actual return value of snmpc_lib:print_error/3 -- it's 'ok'.

I spent a few moments trying to figure out if that could
have been deliberate. I decided it probably wasn't.
Such implicit return values are usually to the detriment
of the reader anywy. The ill effect in this case ought to
be one error printout too many.

/Uffe (now going to bed)



More information about the erlang-questions mailing list