Page MenuHomeFreeBSD

printf.9: Update the example for %D conversion specifier
ClosedPublic

Authored by zlei on Apr 13 2023, 4:03 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Oct 20, 12:45 AM
Unknown Object (File)
Sep 25 2024, 11:36 PM
Unknown Object (File)
Sep 25 2024, 4:59 AM
Unknown Object (File)
Sep 24 2024, 11:26 PM
Unknown Object (File)
Sep 18 2024, 6:03 AM
Unknown Object (File)
Sep 18 2024, 4:13 AM
Unknown Object (File)
Sep 17 2024, 6:29 PM
Unknown Object (File)
Sep 17 2024, 7:12 AM
Subscribers

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

zlei requested review of this revision.Apr 13 2023, 4:03 AM
gbe added a subscriber: gbe.

LGTM from manpages

Markup looks good, but I haven't tested the example itself.

In D39543#900185, @gbe wrote:

LGTM from manpages

Markup looks good, but I haven't tested the example itself.

Tested with a minimal kernel module:
foo.c:

#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/module.h>
#include <sys/kernel.h>

static void
printf_test(void)
{
        printf("reg=%b\n", 3, "\10\2BITTWO\1BITONE");
        printf("out: %4D\n", "AAZZ", ":");
}

/*
 * The function called at load/unload.
 */
static int
load(module_t mod, int cmd, void *arg)
{
        int error;

        error = 0;
        switch (cmd) {
        case MOD_LOAD:
                printf("Load foo\n");
                printf_test();
                break;
        case MOD_UNLOAD:
                printf("Unload foo\n");
                break;
        default:
                error = EOPNOTSUPP;
                break;
        }
        return (error);
}

static moduledata_t mod_data = {
        "foo",
        load,
        0
};

DECLARE_MODULE(foo, mod_data, SI_SUB_EXEC, SI_ORDER_ANY);

Makefile:

#	$FreeBSD$
PACKAGE=foo
SRCS	= foo.c
KMOD	= foo

.include <bsd.kmod.mk>

Steps to test:

# make
# kldload ./foo.ko
# kldunload foo.ko
# dmesg | tail

Load foo
reg=3<BITTWO,BITONE>
out: 41:41:5a:5a
Unload foo
This revision was not accepted when it landed; it landed in state Needs Review.Apr 14 2023, 10:10 AM
This revision was automatically updated to reflect the committed changes.