Re: [master] logging: refactor printLogHeader

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

On 08/16/2010 02:08 AM, Ales Kozumplik wrote:

> +const char *log_level_to_str[LOGLEVEL_MAX + 1] = {
> +    [DEBUGLVL] = "DEBUG",
> +    [INFO] = "INFO",
> +    [WARNING] = "WARN",
> +    [ERROR] = "ERR",
> +    [CRITICAL] = "CRIT"
> +};
> +

Neat! That's the first time I've seen that. It does seem a bit fragile
though -- pass it a wrong index and it segfaults.

> +    level_name = log_level_to_str[level];
> +    fprintf(outfile, "%02d:%02d:%02d,%03d %s %s: ", t->tm_hour,
> +            t->tm_min, t->tm_sec, msecs, level_name, tag);
>  }

level needs a check on it to make sure it is valid. I tried out a
snippet of code to test this and unless you pass it one of the
initializers it will segfault.

- -- 
Brian C. Lane <bcl@xxxxxxxxxx>
Red Hat / Port Orchard, WA
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Remember Lexington Green!

iQEVAwUBTGlzihF+jBaO/jp/AQKWagf/Y2yBnmlOdLZwuK9KeQv1w/0vGRql2hSX
iiy9XxxXDB3XygxfLBlEZQcjr7UKhGVhGK9HRuchXeO6nSJAdv09igUKSs/bszV4
39AFRlPlLTuUsTnDSwX34Zpla48LsmG8E6L+zRhOPB16LkcwWNM71V50qWDb21ki
4UItaFLIZ3yUbulE4K4VN0jSUcttp6UmH7FUerpIW3m9yFBdraZUzbuZgWYFSTXP
Qt76DBvtfMel3y27Ulr+xoTQOukvEao9D9JZlcpz2BURF7nQi9twYpN1A2Sm2AiS
7KGt1BEQm//E56TtIDRxF6iAL2uymWr8Kkzs2rDYmtcbCpKzbl/NMg==
=wp2n
-----END PGP SIGNATURE-----

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux