Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 06 Sep 2024 01:03:01 +0200
From:      Steffen Nurpmeso <steffen@sdaoden.eu>
To:        ske-89@pkmab.se, freebsd-hackers@freebsd.org
Subject:   Re: The Case for Rust (in any system)
Message-ID:  <20240905230301.XxRHheIX@steffen%sdaoden.eu>
In-Reply-To: <20240905225129.UvYYMXDa@steffen%sdaoden.eu>
References:  <202409052313.aa18097@berenice.pkmab.se> <20240905225129.UvYYMXDa@steffen%sdaoden.eu>

next in thread | previous in thread | raw e-mail | index | archive | help

Steffen Nurpmeso wrote in
 <20240905225129.UvYYMXDa@steffen%sdaoden.eu>:
 ...

hihihi saw the Somers .. but wanted to add

 |Ie, if you implement some SCSI command
 ..
 |  we_parse_THIS_SCSI_COMMAND([.]u8 *buf, u16 len){
 |...
 |        /* C99 */{
 |                struct a_mmc_cmd_x42_resp_data_head *dhp;
 |
 |^argument etc of THIS_SCSI_COMMAND
 |
 |                dhp = R(struct a_mmc_cmd_x42_resp_data_head*,buf);
 |                buf += sizeof(*dhp);
 |                len -= sizeof(*dhp);
 |}
 |...
 |        irp = R(struct a_mmc_cmd_x42_isrc_resp*,buf);

This thing tested the lengths accordingly, of course.

  ...
 |very safely in C, if instead of strnlen() etc something more sane
 |would have been used.  Like a string object.  But it is more
 |typing work etc.  *That* of course, yes.

Now Option<Box<Vec<u8>>> or Vec::with_capacity(262144) is not that
much shorter than doing something in C proper types at hand
provided.  (Btw C object constructors usually initialize their
types, too, .. that is why they are called constructors.
Of course: you need these objects, stdlib has none, but FILE,
which is horrific.  Vec<u8>, hmhm...)

  ..etcetcetc.

--steffen
|
|Der Kragenbaer,                The moon bear,
|der holt sich munter           he cheerfully and one by one
|einen nach dem anderen runter  wa.ks himself off
|(By Robert Gernhardt)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20240905230301.XxRHheIX>