ALT Linux Team development discussions
 help / color / mirror / Atom feed
From: php-coder <php-coder@altlinux.ru>
To: devel@lists.altlinux.org
Subject: [devel] Исправление warnings. Нужна помощь
Date: Thu, 08 Dec 2005 16:49:19 +0600
Message-ID: <auto-000286382065@intranet.ru> (raw)


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

    Пытаюсь сделать, чтобы программа на С при компиляции с флагом -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)





             reply	other threads:[~2005-12-08 10:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-12-08 10:49 php-coder [this message]
2005-12-08 17:24 ` Andrey Rahmatullin

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=auto-000286382065@intranet.ru \
    --to=php-coder@altlinux.ru \
    --cc=devel@lists.altlinux.org \
    /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

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