9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Function args not checked
@ 2006-04-17  6:50 Rodolfo (kix)
  2006-04-17  7:00 ` geoff
  2006-04-17 14:52 ` jmk
  0 siblings, 2 replies; 12+ messages in thread
From: Rodolfo (kix) @ 2006-04-17  6:50 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 371 bytes --]

Hi,

I have this definitions:

extern Elem mkoid(Ints *oid); // asn1.h
Ints * snmp_mkoid(char *str); // snmp_asn1.h
char * oids[MAX];

and, this:

myElem = mkoid(snmp_mkoid(oids[0]));

The 8c returns:

x.c:216 function args not checked: snmp_mkoid
x.c:216 argument prototype mismatch "INT" for "IND STRUCT Ints": mkoid

why?

--
Rodolfo García "kix"

[-- Attachment #2: Type: text/html, Size: 463 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [9fans] Function args not checked
  2006-04-17  6:50 [9fans] Function args not checked Rodolfo (kix)
@ 2006-04-17  7:00 ` geoff
  2006-04-17  7:25   ` Rodolfo (kix)
  2006-04-17 14:52 ` jmk
  1 sibling, 1 reply; 12+ messages in thread
From: geoff @ 2006-04-17  7:00 UTC (permalink / raw)
  To: 9fans

It sounds like the header that declares snmp_mkoid isn't being
included in the file that contains

myElem = mkoid(snmp_mkoid(oids[0]));



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [9fans] Function args not checked
  2006-04-17  7:00 ` geoff
@ 2006-04-17  7:25   ` Rodolfo (kix)
  0 siblings, 0 replies; 12+ messages in thread
From: Rodolfo (kix) @ 2006-04-17  7:25 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

[-- Attachment #1: Type: text/plain, Size: 262 bytes --]

Yes!

thanks

On 4/17/06, geoff@collyer.net <geoff@collyer.net> wrote:
>
> It sounds like the header that declares snmp_mkoid isn't being
> included in the file that contains
>
> myElem = mkoid(snmp_mkoid(oids[0]));
>
>


--
Rodolfo García "kix"

[-- Attachment #2: Type: text/html, Size: 603 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [9fans] Function args not checked
  2006-04-17  6:50 [9fans] Function args not checked Rodolfo (kix)
  2006-04-17  7:00 ` geoff
@ 2006-04-17 14:52 ` jmk
  2006-04-17 15:17   ` "Nils O. Selåsdal"
  2006-04-17 15:53   ` Victor Nazarov
  1 sibling, 2 replies; 12+ messages in thread
From: jmk @ 2006-04-17 14:52 UTC (permalink / raw)
  To: 9fans

As an aside, when you declare prototypes I find it is best to
only give the types of the parameters and not declare identifiers,
e.g.
	extern Elem mkoid(Ints *); // asn1.h
rather than
	extern Elem mkoid(Ints *oid); // asn1.h
This prevents confusion in environments where there is overuse
of the pre-processor and the identifier gets substituted.

--jim

On Mon Apr 17 02:51:00 EDT 2006, rodolfogarciap@gmail.com wrote:
> 
> Hi,
> 
> I have this definitions:
> 
> extern Elem mkoid(Ints *oid); // asn1.h
> Ints * snmp_mkoid(char *str); // snmp_asn1.h
> char * oids[MAX];
> 
> and, this:
> 
> myElem = mkoid(snmp_mkoid(oids[0]));
> 
> The 8c returns:
> 
> x.c:216 function args not checked: snmp_mkoid
> x.c:216 argument prototype mismatch "INT" for "IND STRUCT Ints": mkoid
> 
> why?
> 
> --
> Rodolfo García "kix"
> 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [9fans] Function args not checked
  2006-04-17 14:52 ` jmk
@ 2006-04-17 15:17   ` "Nils O. Selåsdal"
  2006-04-17 15:28     ` David Leimbach
  2006-04-17 15:53   ` Victor Nazarov
  1 sibling, 1 reply; 12+ messages in thread
From: "Nils O. Selåsdal" @ 2006-04-17 15:17 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

jmk@plan9.bell-labs.com wrote:
> As an aside, when you declare prototypes I find it is best to
> only give the types of the parameters and not declare identifiers,
> e.g.
> 	extern Elem mkoid(Ints *); // asn1.h
> rather than
> 	extern Elem mkoid(Ints *oid); // asn1.h
> This prevents confusion in environments where there is overuse
> of the pre-processor and the identifier gets substituted.

Valid point,but I find the names quite helpful and of documentary
value -  perhaps it's a defect of mine after reading too much
non-obvious code.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [9fans] Function args not checked
  2006-04-17 15:17   ` "Nils O. Selåsdal"
@ 2006-04-17 15:28     ` David Leimbach
  2006-04-17 15:31       ` jmk
  0 siblings, 1 reply; 12+ messages in thread
From: David Leimbach @ 2006-04-17 15:28 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On 4/17/06, "Nils O. Selåsdal" <noselasd@asgaard.homelinux.org> wrote:
> jmk@plan9.bell-labs.com wrote:
> > As an aside, when you declare prototypes I find it is best to
> > only give the types of the parameters and not declare identifiers,
> > e.g.
> >       extern Elem mkoid(Ints *); // asn1.h
> > rather than
> >       extern Elem mkoid(Ints *oid); // asn1.h
> > This prevents confusion in environments where there is overuse
> > of the pre-processor and the identifier gets substituted.
>
> Valid point,but I find the names quite helpful and of documentary
> value -  perhaps it's a defect of mine after reading too much
> non-obvious code.
>

Well a lot of people fall back to header files for documentation
purposes, and looking headers to figure out which of the "char *'s" is
a source and which is a destination in some cases is nice.

Nothing that can't be solved with good comments and man pages though.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [9fans] Function args not checked
  2006-04-17 15:28     ` David Leimbach
@ 2006-04-17 15:31       ` jmk
  2006-04-17 15:40         ` Paul Lalonde
  0 siblings, 1 reply; 12+ messages in thread
From: jmk @ 2006-04-17 15:31 UTC (permalink / raw)
  To: 9fans

Prototypes are not documentation.

On Mon Apr 17 11:29:34 EDT 2006, leimy2k@gmail.com wrote:
> On 4/17/06, "Nils O. Selåsdal" <noselasd@asgaard.homelinux.org> wrote:
> > jmk@plan9.bell-labs.com wrote:
> > > As an aside, when you declare prototypes I find it is best to
> > > only give the types of the parameters and not declare identifiers,
> > > e.g.
> > >       extern Elem mkoid(Ints *); // asn1.h
> > > rather than
> > >       extern Elem mkoid(Ints *oid); // asn1.h
> > > This prevents confusion in environments where there is overuse
> > > of the pre-processor and the identifier gets substituted.
> >
> > Valid point,but I find the names quite helpful and of documentary
> > value -  perhaps it's a defect of mine after reading too much
> > non-obvious code.
> >
> 
> Well a lot of people fall back to header files for documentation
> purposes, and looking headers to figure out which of the "char *'s" is
> a source and which is a destination in some cases is nice.
> 
> Nothing that can't be solved with good comments and man pages though.


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [9fans] Function args not checked
  2006-04-17 15:31       ` jmk
@ 2006-04-17 15:40         ` Paul Lalonde
  2006-04-17 16:30           ` Skip Tavakkolian
  0 siblings, 1 reply; 12+ messages in thread
From: Paul Lalonde @ 2006-04-17 15:40 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On 17-Apr-06, at 8:31 AM, jmk@plan9.bell-labs.com wrote:

> Prototypes are not documentation.

Absolutely.  But they have a better chance of reflecting reality.

Not everyone is blessed to work on good code bases.  Until then, I'll  
keep "documenting" my prototypes with good names.

Paul

>
> On Mon Apr 17 11:29:34 EDT 2006, leimy2k@gmail.com wrote:
>> On 4/17/06, "Nils O. Selåsdal" <noselasd@asgaard.homelinux.org>  
>> wrote:
>>> jmk@plan9.bell-labs.com wrote:
>>>> As an aside, when you declare prototypes I find it is best to
>>>> only give the types of the parameters and not declare identifiers,
>>>> e.g.
>>>>       extern Elem mkoid(Ints *); // asn1.h
>>>> rather than
>>>>       extern Elem mkoid(Ints *oid); // asn1.h
>>>> This prevents confusion in environments where there is overuse
>>>> of the pre-processor and the identifier gets substituted.
>>>
>>> Valid point,but I find the names quite helpful and of documentary
>>> value -  perhaps it's a defect of mine after reading too much
>>> non-obvious code.
>>>
>>
>> Well a lot of people fall back to header files for documentation
>> purposes, and looking headers to figure out which of the "char  
>> *'s" is
>> a source and which is a destination in some cases is nice.
>>
>> Nothing that can't be solved with good comments and man pages though.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFEQ7cEpJeHo/Fbu1wRAnhfAKDFwmHNnIaZgveun50Tkqq43OuSBwCgmp6C
+HRZ02LcjezPFri/8RrkuP0=
=eds8
-----END PGP SIGNATURE-----


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [9fans] Function args not checked
  2006-04-17 14:52 ` jmk
  2006-04-17 15:17   ` "Nils O. Selåsdal"
@ 2006-04-17 15:53   ` Victor Nazarov
  2006-04-17 16:00     ` Devon H. O'Dell
  1 sibling, 1 reply; 12+ messages in thread
From: Victor Nazarov @ 2006-04-17 15:53 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

jmk@plan9.bell-labs.com wrote:

>As an aside, when you declare prototypes I find it is best to
>only give the types of the parameters and not declare identifiers,
>e.g.
>	extern Elem mkoid(Ints *); // asn1.h
>rather than
>	extern Elem mkoid(Ints *oid); // asn1.h
>This prevents confusion in environments where there is overuse
>of the pre-processor and the identifier gets substituted.
>
>
It's just an evidence of preprocessor's danger. Let's use enums. IMHO,
prototypes are quite good documentation sometimes.
--
Victor Nazarov



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [9fans] Function args not checked
  2006-04-17 15:53   ` Victor Nazarov
@ 2006-04-17 16:00     ` Devon H. O'Dell
  0 siblings, 0 replies; 12+ messages in thread
From: Devon H. O'Dell @ 2006-04-17 16:00 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

2006/4/17, Victor Nazarov <vir@comtv.ru>:
> jmk@plan9.bell-labs.com wrote:
>
> >As an aside, when you declare prototypes I find it is best to
> >only give the types of the parameters and not declare identifiers,
> >e.g.
> >       extern Elem mkoid(Ints *); // asn1.h
> >rather than
> >       extern Elem mkoid(Ints *oid); // asn1.h
> >This prevents confusion in environments where there is overuse
> >of the pre-processor and the identifier gets substituted.
> >
> >
> It's just an evidence of preprocessor's danger. Let's use enums. IMHO,
> prototypes are quite good documentation sometimes.

Until someone reorders arguments and forgets to update the prototype
to reflect them. Using argument names in your prototypes is not an
excuse to not write documentation on your API. It is an excuse to be
lazy.

--Devon

> --
> Victor Nazarov
>
>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [9fans] Function args not checked
  2006-04-17 15:40         ` Paul Lalonde
@ 2006-04-17 16:30           ` Skip Tavakkolian
  2006-04-17 20:43             ` Don Bailey
  0 siblings, 1 reply; 12+ messages in thread
From: Skip Tavakkolian @ 2006-04-17 16:30 UTC (permalink / raw)
  To: 9fans

>> Prototypes are not documentation.
>
> Absolutely.  But they have a better chance of reflecting reality.
>
> Not everyone is blessed to work on good code bases.  Until then, I'll
> keep "documenting" my prototypes with good names.

variable naming conventions are not enforced by the compiler; they
could be misleading.  why not use an ide - e.g.  eclipse is available
for many platforms - or just document the code.  using cweb will
exhibit your STRONG commitment to good documentation :)



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [9fans] Function args not checked
  2006-04-17 16:30           ` Skip Tavakkolian
@ 2006-04-17 20:43             ` Don Bailey
  0 siblings, 0 replies; 12+ messages in thread
From: Don Bailey @ 2006-04-17 20:43 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

> variable naming conventions are not enforced by the compiler; they
> could be misleading.  why not use an ide - e.g.  eclipse is available
> for many platforms - or just document the code.  using cweb will
> exhibit your STRONG commitment to good documentation :)
>

I used to have a problem deciding how to keep track of
IN and OUT arguments in functions. Rather than bothering
to clutter up prototypes with names, I came up with this
simple technique:

	for
		anyfunction(IN * A, IN * B, IN * C, OUT * A)

Variables used as input to the given function will be sent
first, in alphabetical order by type. Output variables will be
sent next, alphabetically by type.

Thus,
	str->dup(char *, char ** );

Even without the second indirection giving us an obvious
clue, we know that the first variable is input and the second
is output.

Because I stick to this as a strict part of my API, I never have
to check the source to remind myself what I'm doing.

Just thought I'd give my two cents.

Don "north" Bailey



-----BEGIN PGP SIGNATURE-----
Version: PGP Desktop 9.0.6 (Build 6060)

iQA/AwUBREP94V/Ie1ANMtLuEQIVtQCfVWiWpqI6Tm0/mhhGFYGw82vPdJMAn24k
t6Kdoj1SWPR9iuSEGOc1/NGd
=6JoQ
-----END PGP SIGNATURE-----



^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2006-04-17 20:43 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-17  6:50 [9fans] Function args not checked Rodolfo (kix)
2006-04-17  7:00 ` geoff
2006-04-17  7:25   ` Rodolfo (kix)
2006-04-17 14:52 ` jmk
2006-04-17 15:17   ` "Nils O. Selåsdal"
2006-04-17 15:28     ` David Leimbach
2006-04-17 15:31       ` jmk
2006-04-17 15:40         ` Paul Lalonde
2006-04-17 16:30           ` Skip Tavakkolian
2006-04-17 20:43             ` Don Bailey
2006-04-17 15:53   ` Victor Nazarov
2006-04-17 16:00     ` Devon H. O'Dell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).