From 5940dd9faaeb3f134284bd16c77bf1626fd5ed92 Mon Sep 17 00:00:00 2001 From: RinHizakura Date: Wed, 4 Aug 2021 23:42:10 +0800 Subject: [PATCH] Revise hello-5 and its output (#38) For the example module hello_5, the book showed the incorrect output in corresponding with its execution results. In addition, this patch changes from myintArray[2] = {-1, -1} to myintArray[2] = {420, 420}, which help the readers distinguish from the kernel messages. --- examples/hello-5.c | 2 +- lkmpg.tex | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/examples/hello-5.c b/examples/hello-5.c index edc11eb..414c994 100644 --- a/examples/hello-5.c +++ b/examples/hello-5.c @@ -13,7 +13,7 @@ static short int myshort = 1; static int myint = 420; static long int mylong = 9999; static char *mystring = "blah"; -static int myintArray[2] = {-1, -1}; +static int myintArray[2] = {420, 420}; static int arr_argc = 0; /* diff --git a/lkmpg.tex b/lkmpg.tex index b87b969..5243270 100644 --- a/lkmpg.tex +++ b/lkmpg.tex @@ -408,20 +408,24 @@ I would recommend playing around with this code: \begin{code} $ sudo insmod hello-5.ko mystring="bebop" myintArray=-1 myshort is a short integer: 1 -myint is an integer: 20 +myint is an integer: 420 mylong is a long integer: 9999 mystring is a string: bebop -myintArray is -1 and 420 +myintArray[0] = -1 +myintArray[1] = 420 +got 1 arguments for myintArray. $ sudo rmmod hello-5 Goodbye, world 5 $ sudo insmod hello-5.ko mystring="supercalifragilisticexpialidocious" myintArray=-1,-1 myshort is a short integer: 1 -myint is an integer: 20 +myint is an integer: 420 mylong is a long integer: 9999 mystring is a string: supercalifragilisticexpialidocious -myintArray is -1 and -1 +myintArray[0] = -1 +myintArray[1] = -1 +got 2 arguments for myintArray. $ sudo rmmod hello-5 Goodbye, world 5