Re: [LTP] [PATCH 4/4] lib: add tst_res_r.c

Mike Frysinger
2014-02-13T08:48:04Z

[-- Attachment #1.1: Type: text/plain, Size: 1095 bytes --]

On Tuesday, February 11, 2014 13:48:10 Alexey Kodanev wrote:
> +static int get_tst_count()

random note: never never never use () with functions. always always always
use (void). i'm guessing you're not aware, but what you've written here may
be called (warning free!) like so:
get_tst_count(1, 2, 3);

yes, even with -W -Wall -Wextra. please stamp this horrible habit out of your
code.

> + /*
> + * Build the result line and print it.
> + */
> + type = strttype(ttype);
> + if (T_mode == VERBOSE) {
> + size = snprintf(message, sizeof(message),
> + "%-8s %4d %s : %s", tcid, tnum, type, tmesg);
> + } else {
> + size = snprintf(message, sizeof(message),
> + "%-8s %4d %s : %s",
> + tcid, tnum, type, tmesg);
> + }
> +
> + if (size >= sizeof(message)) {
> + printf("%s: %i: line too long\n", __func__, __LINE__);
> + abort();
> + }

ugh, the 90's called and they want their staticly defined stack buffers back.
use asprintf() and throw this historical wart in the trash where it belongs.

i've cleaned up tst_res.c some.
-mike

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

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

------------------------------------------------------------------------------
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
Now with support for Jelly Bean, Bluetooth, Mapview and more.
Get your Android app in front of a whole new audience. Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk

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