public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: ltp-list@lists.sourceforge.net
Cc: Alexey Kodanev <alexey.kodanev@oracle.com>, vasily.isaenko@oracle.com
Subject: Re: [LTP] [PATCH] tst_module: create new library functions for kernel modules
Date: Sat, 22 Jun 2013 14:15:15 -0400	[thread overview]
Message-ID: <201306221415.17130.vapier@gentoo.org> (raw)
In-Reply-To: <1371729277-12450-1-git-send-email-alexey.kodanev@oracle.com>


[-- Attachment #1.1: Type: Text/Plain, Size: 1494 bytes --]

On Thursday 20 June 2013 07:54:37 Alexey Kodanev wrote:
> +/*
> + * Check module existence.
> + *
> + * @res_path: if this pointer isn't NULL, found module's path will be
> + * written to it.
> + *
> + * In case of failure, test'll call cleanup_fn and exit with TCONF return
> + */
> +void tst_module_exist(void (*cleanup_fn)(void), const char *mod_name,
> +	char *res_path, size_t max_path);

i hate APIs like this.  they're so 1990 :P.

look at the getline() func and behave like that instead (take char **res_path 
and size_t *max_path instead)

> +/* declared in tst_tmpdir.c */
> +const char *tst_get_startwd(void);

use a proper header instead.  extern func decls only leads to bit rot and hard 
to debug crashes.

> +	char buf[PATH_MAX];

PATH_MAX should be taken out back and shot.  there's no reason to use it 
anymore when we have things like asprintf().  plus, it isn't portable -- 
there's no guarantee it'll be defined.  i know the irony complaining about 
portability with PATH_MAX when asprintf() isn't in POSIX either, but the 
difference is, we have an asprintf() fallback already in lib/, and we have code 
using it today.

> +	char cmd[strlen(mod_path) + strlen(params) + 9];
> +	snprintf(cmd, sizeof(cmd), "insmod %s %s", mod_path, params);
> +
> +	if (system(cmd) != 0) {

use fork()+execvp() instead.  there's no need to normalize to a string and 
then run through a shell.

wonder if we should add a util func for this ...
-mike

[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 184 bytes --]

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev

[-- Attachment #3: Type: text/plain, Size: 155 bytes --]

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

  reply	other threads:[~2013-06-22 18:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-20 11:54 [LTP] [PATCH] tst_module: create new library functions for kernel modules Alexey Kodanev
2013-06-22 18:15 ` Mike Frysinger [this message]
2013-06-24 10:01   ` alexey.kodanev
2013-06-24 15:29     ` Mike Frysinger
2013-06-24 11:56   ` chrubis
     [not found]     ` <201306241136.07004.vapier@gentoo.org>
2013-06-24 15:43       ` chrubis
2013-06-24 16:02         ` chrubis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201306221415.17130.vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=alexey.kodanev@oracle.com \
    --cc=ltp-list@lists.sourceforge.net \
    --cc=vasily.isaenko@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox