Subject: Re: Porting code with switch/case on mount type (was int)
To: Christos Zoulas <christos@zoulas.com>
From: Chris G. Demetriou <cgd@netbsd.org>
List: current-users
Date: 05/17/1999 14:35:02
christos@zoulas.com (Christos Zoulas) writes:
> In article <19990517171041.A23129@fundy.ca> david@fundy.ca (David Maxwell) writes:
> >I see that our first argument to mount is a const char now, (not sure when
> >it happened) and I'm porting some code from FreeBSD that does a switch on
> >the mount 'type' (first arg), which used to be an int, and still is for 
> >them.

FYI, the change was made ... a _long_ time ago.  from the cvs log of
vfs_syscalls.c:

revision 1.19
date: 1994/04/14 04:05:32;  author: cgd;  state: Exp;  lines: +1 -1
fs types are names now; accompanying changes.

wow, more than 5 years ago, in fact.


> >Any suggestions on a preffered way of recoding a switch/case block of
> >C, now that we have a const char there?
> 
> Dunno, if (strcmp(..) == 0) {
>        } else if (strcmp(..) == 0) {
>        } ...

That's certainly the easiest, and what I've done whent there's no need
to do more.

if you have some weird performance needs, you could use a hash
function/table or something, but that's always seemed like overkill to
me.



cgd
-- 
Chris Demetriou - cgd@netbsd.org - http://www.netbsd.org/People/Pages/cgd.html
Disclaimer: Not speaking for NetBSD, just expressing my own opinion.