MESSAGE
DATE | 2018-07-25 |
FROM | valdis.kletnieks@vt.edu
|
SUBJECT | Re: [Hangout - NYLXS] Need Suggestions
|
From hangout-bounces-at-nylxs.com Wed Aug 1 17:28:38 2018 Return-Path: X-Original-To: archive-at-mrbrklyn.com Delivered-To: archive-at-mrbrklyn.com Received: from www2.mrbrklyn.com (www2.mrbrklyn.com [96.57.23.82]) by mrbrklyn.com (Postfix) with ESMTP id 1B44216113A; Wed, 1 Aug 2018 17:28:34 -0400 (EDT) X-Original-To: hangout-at-www2.mrbrklyn.com Delivered-To: hangout-at-www2.mrbrklyn.com Received: by mrbrklyn.com (Postfix, from userid 1000) id CA96F161134; Wed, 1 Aug 2018 17:28:28 -0400 (EDT) Resent-From: Ruben Safir Resent-Date: Wed, 1 Aug 2018 17:28:28 -0400 Resent-Message-ID: <20180801212828.GA8690-at-www2.mrbrklyn.com> Resent-To: hangout-at-mrbrklyn.com X-Original-To: ruben-at-mrbrklyn.com Delivered-To: ruben-at-mrbrklyn.com Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) by mrbrklyn.com (Postfix) with ESMTP id 12A1B161132 for ; Wed, 25 Jul 2018 18:10:40 -0400 (EDT) Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.90_1) (envelope-from ) id 1fiRzN-0002cS-Ud; Wed, 25 Jul 2018 18:10:33 -0400 Received: from omr1.cc.ipv6.vt.edu ([2607:b400:92:8300:0:c6:2117:b0e] helo=omr1.cc.vt.edu) by shelob.surriel.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1fiRzI-0002cM-GT for Kernelnewbies-at-kernelnewbies.org; Wed, 25 Jul 2018 18:10:28 -0400 Received: from mr5.cc.vt.edu (mr5.cc.vt.edu [IPv6:2607:b400:92:8400:0:72:232:758b]) by omr1.cc.vt.edu (8.14.4/8.14.4) with ESMTP id w6PMANVo032231 for ; Wed, 25 Jul 2018 18:10:27 -0400 Received: from mail-qk0-f199.google.com (mail-qk0-f199.google.com [209.85.220.199]) by mr5.cc.vt.edu (8.14.7/8.14.7) with ESMTP id w6PMAIUj025227 for ; Wed, 25 Jul 2018 18:10:23 -0400 Received: by mail-qk0-f199.google.com with SMTP id o18-v6so7794330qko.21 for ; Wed, 25 Jul 2018 15:10:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:in-reply-to:references :mime-version:content-transfer-encoding:date:message-id; bh=/wbF2CPELvT2dox7wgo7M2A8nIH6dChoBvxqfdmo/Pc=; b=JHvB3kvRLhXONoSuAo4vgKlM5hCNpGanuZFaaIjNr7ocn5XgMlVeFXhQIYVke/EK2S XHa24LTCvN3w8r3Xakal7FnObTKDEOgJEFsjGbAAjXWPM/SCZT+aCgevOos7l/5Jzk6t AIg/TCWNhDBr+JqLT9frlllcoLVOxeBMO/edeB0GpIORaW7d2xgE4bpCSPcPl8Ksy/Ug H4olEBv+90w2O9v4ScJ+B2zr8HQgdj7sZ+mz9slJPWXY0S0xQwjpGWKfe6mUYM7moqO8 gqlVVnPGfCe359kp/FnLNluUbzoE3zE9/mUoBsu2THGwGGE4MjFMUbClQWi8UfgFjer1 /TQw== X-Gm-Message-State: AOUpUlF/s2KJJ9x9/Wg6AhmEhiNAfnCp1JYNhLOB1U7JhTXM3MTSGu8O yiyF7eg7WU6dqPxke5kjIkHoCtAiB/XTy2gkhdf7w2E+MLab3ucs+vkfZV7e0lT4FD2pT+OGW6v mPBiBVSTevhM0Q37pCtUdET2BxFaC2VQujiTNKnM= X-Received: by 2002:ac8:3f54:: with SMTP id w20-v6mr21199076qtk.91.1532556618448; Wed, 25 Jul 2018 15:10:18 -0700 (PDT) X-Google-Smtp-Source: AAOMgpefdGzeAUOkJS9F8ZPj7nSmo50d2fmZF45ImSG3F99P6tnYR9UqwVMK2Iye8i8MaQOgSFHMVw== X-Received: by 2002:ac8:3f54:: with SMTP id w20-v6mr21199065qtk.91.1532556618226; Wed, 25 Jul 2018 15:10:18 -0700 (PDT) Received: from turing-police.cc.vt.edu (turing-police.cc.ipv6.vt.edu. [2001:468:c80:2103:f21f:afff:fe0c:8ada]) by smtp.gmail.com with ESMTPSA id u21-v6sm10143917qka.88.2018.07.25.15.10.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Jul 2018 15:10:16 -0700 (PDT) From: valdis.kletnieks-at-vt.edu X-Google-Original-From: Valdis.Kletnieks-at-vt.edu X-Mailer: exmh version 2.8.0 04/21/2017 with nmh-1.7+dev To: Himanshu Jha In-Reply-To: <20180725213727.GA9993-at-himanshu-Vostro-3559> References: <20180725213727.GA9993-at-himanshu-Vostro-3559> Mime-Version: 1.0 Date: Wed, 25 Jul 2018 18:10:16 -0400 Message-ID: <203226.1532556616-at-turing-police.cc.vt.edu> X-BeenThere: kernelnewbies-at-kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Archive: Content-Type: multipart/mixed; boundary="===============5311157160313286230==" Cc: inventsekar , Athul Joy , Kernelnewbies-at-kernelnewbies.org Subject: Re: [Hangout - NYLXS] Need Suggestions X-BeenThere: hangout-at-nylxs.com List-Id: NYLXS Tech Talk and Politics List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: hangout-bounces-at-nylxs.com Sender: "Hangout"
--===============5311157160313286230== Content-Type: multipart/signed; boundary="==_Exmh_1532556616_2847P"; micalg=pgp-sha1; protocol="application/pgp-signature" Content-Transfer-Encoding: 7bit
--==_Exmh_1532556616_2847P Content-Type: text/plain; charset=us-ascii
On Thu, 26 Jul 2018 03:07:27 +0530, Himanshu Jha said:
> Now, this part of section is really important and somehow if you think > you really learnt C well in the course offered at University. Then > please take a look at implicit conversions: > https://en.cppreference.com/w/c/language/conversion > > assert(sizeof(int) > -1); > > That should be enough to shatter your confidence.
If you want your confidence shaken:
https://www.lysator.liu.se/c/duffs-device.html
Fortunately, most maintainers will frown on stuff like that unless there's a *damned* good reason - and Tom Duff had a very good reason indeed.
(Intro-to-c pop quiz - why is strcpy() not usable here?)
gcc 8.1.1 will accept Tom's code (with 3 warnings due to it being pre-ANSI C).
For those who took a class on compiler design, and *think* they know how LALR parsers and that stuff works - Examine the lexical nesting of that, and figure out how the devil the compiler doesn't get indigestion.. :)
And the K&R book on C does successive trimming of an strcpy(), and finishes with
void strcpy(char *a, *b) { while (*a++ = *b++); }
The thing that's actually used a lot in the Linux kernel that gives a lot of C newcomers heartburn is the widespread use of structures of function pointers.. For example, this from include/linux/fs.h:
struct lock_manager_operations { int (*lm_compare_owner)(struct file_lock *, struct file_lock *); unsigned long (*lm_owner_key)(struct file_lock *); fl_owner_t (*lm_get_owner)(fl_owner_t); void (*lm_put_owner)(fl_owner_t); void (*lm_notify)(struct file_lock *); /* unblock callback */ int (*lm_grant)(struct file_lock *, int); bool (*lm_break)(struct file_lock *); int (*lm_change)(struct file_lock *, int, struct list_head *); void (*lm_setup)(struct file_lock *, void **); };
That's the structure definition. Novice challenge: Find one or more places where this structure is initialized, and understand how and why that works.
--==_Exmh_1532556616_2847P Content-Type: application/pgp-signature
-----BEGIN PGP SIGNATURE----- Comment: Exmh version 2.8.0 04/21/2017
iQEVAwUBW1j1SI0DS38y7CIcAQJL5wf/RPsHWU7eYTa4PDeWvCjXiuPbK889Y1xE 6NW9dr+ckfmr2+Sxn0oUKXeexoSl63EBt4HcsWD8hkeCxdjg8Qa/H8bgOLAy7acN 75qsvUripBd1vo25LXJ4BL2KRRivhticQ0hJU9cRB+OHDIefFZ1hNZQv++IBnIYk 4LakqGf+c5078SKz8qag3Cj4eHg3ZqzZ3hsRf7C4mDxpRjAsFwi6Ut0D9vNjpDKZ /X0s5vN/M5opoW9L6ky73quPB0W8HgFpu4/xB5xlgrZ/rBV8lJR0/y14jMUVyO1Q eE3B6LbVar8P0X2zoN2Ic2XQH18YLGMDqM/epw1ChCHFF/qj6y3opw== =SpHb -----END PGP SIGNATURE-----
--==_Exmh_1532556616_2847P--
--===============5311157160313286230== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline
_______________________________________________ Kernelnewbies mailing list Kernelnewbies-at-kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
--===============5311157160313286230== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline
_______________________________________________ Hangout mailing list Hangout-at-nylxs.com http://lists.mrbrklyn.com/mailman/listinfo/hangout
--===============5311157160313286230==--
--===============5311157160313286230== Content-Type: multipart/signed; boundary="==_Exmh_1532556616_2847P"; micalg=pgp-sha1; protocol="application/pgp-signature" Content-Transfer-Encoding: 7bit
--==_Exmh_1532556616_2847P Content-Type: text/plain; charset=us-ascii
On Thu, 26 Jul 2018 03:07:27 +0530, Himanshu Jha said:
> Now, this part of section is really important and somehow if you think > you really learnt C well in the course offered at University. Then > please take a look at implicit conversions: > https://en.cppreference.com/w/c/language/conversion > > assert(sizeof(int) > -1); > > That should be enough to shatter your confidence.
If you want your confidence shaken:
https://www.lysator.liu.se/c/duffs-device.html
Fortunately, most maintainers will frown on stuff like that unless there's a *damned* good reason - and Tom Duff had a very good reason indeed.
(Intro-to-c pop quiz - why is strcpy() not usable here?)
gcc 8.1.1 will accept Tom's code (with 3 warnings due to it being pre-ANSI C).
For those who took a class on compiler design, and *think* they know how LALR parsers and that stuff works - Examine the lexical nesting of that, and figure out how the devil the compiler doesn't get indigestion.. :)
And the K&R book on C does successive trimming of an strcpy(), and finishes with
void strcpy(char *a, *b) { while (*a++ = *b++); }
The thing that's actually used a lot in the Linux kernel that gives a lot of C newcomers heartburn is the widespread use of structures of function pointers.. For example, this from include/linux/fs.h:
struct lock_manager_operations { int (*lm_compare_owner)(struct file_lock *, struct file_lock *); unsigned long (*lm_owner_key)(struct file_lock *); fl_owner_t (*lm_get_owner)(fl_owner_t); void (*lm_put_owner)(fl_owner_t); void (*lm_notify)(struct file_lock *); /* unblock callback */ int (*lm_grant)(struct file_lock *, int); bool (*lm_break)(struct file_lock *); int (*lm_change)(struct file_lock *, int, struct list_head *); void (*lm_setup)(struct file_lock *, void **); };
That's the structure definition. Novice challenge: Find one or more places where this structure is initialized, and understand how and why that works.
--==_Exmh_1532556616_2847P Content-Type: application/pgp-signature
-----BEGIN PGP SIGNATURE----- Comment: Exmh version 2.8.0 04/21/2017
iQEVAwUBW1j1SI0DS38y7CIcAQJL5wf/RPsHWU7eYTa4PDeWvCjXiuPbK889Y1xE 6NW9dr+ckfmr2+Sxn0oUKXeexoSl63EBt4HcsWD8hkeCxdjg8Qa/H8bgOLAy7acN 75qsvUripBd1vo25LXJ4BL2KRRivhticQ0hJU9cRB+OHDIefFZ1hNZQv++IBnIYk 4LakqGf+c5078SKz8qag3Cj4eHg3ZqzZ3hsRf7C4mDxpRjAsFwi6Ut0D9vNjpDKZ /X0s5vN/M5opoW9L6ky73quPB0W8HgFpu4/xB5xlgrZ/rBV8lJR0/y14jMUVyO1Q eE3B6LbVar8P0X2zoN2Ic2XQH18YLGMDqM/epw1ChCHFF/qj6y3opw== =SpHb -----END PGP SIGNATURE-----
--==_Exmh_1532556616_2847P--
--===============5311157160313286230== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline
_______________________________________________ Kernelnewbies mailing list Kernelnewbies-at-kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
--===============5311157160313286230== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline
_______________________________________________ Hangout mailing list Hangout-at-nylxs.com http://lists.mrbrklyn.com/mailman/listinfo/hangout
--===============5311157160313286230==--
|
|