ALT Linux Team development discussions
 help / color / mirror / Atom feed
* [devel] Исправление warnings. Нужна помощь
@ 2005-12-08 10:49 php-coder
  2005-12-08 17:24 ` Andrey Rahmatullin
  0 siblings, 1 reply; 2+ messages in thread
From: php-coder @ 2005-12-08 10:49 UTC (permalink / raw)
  To: devel


    Здравствуйте!

    Пытаюсь сделать, чтобы программа на С при компиляции с флагом -Wall не
    выдавала никаких warning'ов. Но сам немножко испугался кода и решил
    попросить помощи у вас.

    1)

    cpu_linux.c: In function `cpu_init':
    cpu_linux.c:63: warning: use of assignment suppression and length
    modifier together in scanf format
    [ и так ещё 5 раз в этой строчке ]

    вот кусок кода:

    static int is_linux26;
    ...
    unsigned long long softirq;
    ...
    is_linux26 = fscanf(fp, "%*s  %*llu %*llu %*llu %*llu %*llu %*llu
    %llu", &softirq);

    Читают файл /proc/stat. Что здесь не правильно? (полагаю, что
    количество %X не совпадает с количеством переменных в fscanf ?)

    2)

    cpu_linux.c: In function `cpu_get_usage':
    cpu_linux.c:93: warning: unsigned int format, different type arg (arg 3)
    cpu_linux.c:93: warning: unsigned int format, different type arg (arg 4)
    cpu_linux.c:93: warning: unsigned int format, different type arg (arg 5)
    cpu_linux.c:93: warning: long unsigned int format, different type arg
    (arg 6)

    Кусок кода:

    unsigned long long user, nice, system, idle, iowait, irq, softirq;
    ...
    if (opts->cpu_number == -1) {
        if (is_linux26)
            fscanf(fp, "%*s  %llu %llu %llu %llu %llu %llu %llu",
                   &user, &nice, &system, &idle, &iowait, &irq, &softirq);
        else
            fscanf(fp, "%*s  %u %u %u %lu", &user, &nice, &system, &idle);
    ...

    Думаю, что надо привести во втором fscanf'e всё как в первом, т.е.
    %llu вместо %u. Ничего страшного при этом не произойдет?

    3)

    main.c: In function `redraw':
    main.c:223: warning: 'backdrop' might be used uninitialized in this
    function

    Вот код:

    Pixmap backdrop;

    switch (backlight) {
    case LIGHTON:
        backdrop = backdrop_on;
        x = 2;
        break;
    case LIGHTOFF:
        backdrop = backdrop_off;
        x = 0;
        break;
    }

    Хочу добавить сюда defaults, только вот что туда написать? Точнее,
    не знаю каким значением инициализировать переменную backdrop ?


    Буду благодарен за вашу помощь! Мммм... может быть не надо было это
    всё сюда писать? Здесь вообще можно такие вопросы задавать или мне
    лучше в ru_programming такое постить?

    Спасибо за внимание!

-- 
+ php-coder
+ php-coder[at]altlinux[dot]ru

>"Будущее проекта рабочей среды GNOME выглядит довольно светло"
А с настоящим-то как? Судя по прочитанному, настоящее выглядит
довольно темно :-))
		-- Ron (linux.org.ru)





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2005-12-08 17:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-12-08 10:49 [devel] Исправление warnings. Нужна помощь php-coder
2005-12-08 17:24 ` Andrey Rahmatullin

ALT Linux Team development discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
		devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
	public-inbox-index devel

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git