vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| On Fri, 13 May 2005, Han Boetes wrote: > Otto Moerbeek wrote: > > This angel has problem with KNF: > > Ow yes: int\nmain(... > > > > space between function name and arg list. Also, return (expr); > > is preferred to return expr; > > It strikes me as inconsistent. I'd expect either ``return 0;'' or > ``return(0)'' but not ``return (0)''. Any pointer to the reason > behind this? I can't find it in style(9). It's the same pattern as function call vs keyword: if (sometest) functioncall(); > > But the main point: you did not make clear why stderr would be > > better. > > Because it's an errormessage. Errormessages should be sent to > stderr. I tried login in to a disabled account to see if the I do not think it is an error message. It is not an error to have /sbin/nologin in the passwd file. It's just a message to the user, like the motd. > errormessage was not echoed but that was also not the case. That > why I was informing if there were any other objections to sending > the message to stderr. It was not a rhetorical question, nor was I do not follow this. The message is displayed if authentication succeeds. After that the connection is closed. > my patch a suggestion nor a recommendation. It was merely meant to > clarify what I had in mind. -Otto > > But now after taking your remarks in account, this is what the > code should look like in the end. After applying one patch for the > functional change and one for the format. (without the license for > briefness): > > [snip: licensenote] > #include <sys/types.h> > #include <fcntl.h> > #include <stdio.h> > #include <string.h> > #include <unistd.h> > > /* Distinctly different from _PATH_NOLOGIN. */ > #define _PATH_NOLOGIN_TXT "/etc/nologin.txt" > > #define DEFAULT_MESG "This account is currently not available.\n" > > /*ARGSUSED*/ > int > main(int argc, char *argv[]) > { > int nfd; > ssize_t nrd; > char nbuf[BUFSIZ]; > > nfd = open(_PATH_NOLOGIN_TXT, O_RDONLY); > if (nfd == -1) { > write(STDERR_FILENO, DEFAULT_MESG, strlen(DEFAULT_MESG)); > return (1); > } > > while ((nrd = read(nfd, nbuf, sizeof(nbuf))) != -1 && nrd != 0) > write(STDERR_FILENO, nbuf, nrd); > > close(nfd); > return (1); > } > > What say you? > > > > # Han |
| Thread Tools | |
| Display Modes | |
|
|