Naming variables and arguments

I rewatched recently a C++ conference video:

CppCon 2018: Kate Gregory “What Do We Mean When We Say Nothing At All?”

Then I did some research and posted a comment which YouTube decided to remove because it detected “Spam, deceptive practices, & scams policies” violation.It didn’t provide any detail, or a way to check what the comment was or appeal the removal. Nice! I was only able to find out which comment it was by looking at my Your YouTube Comments history and see which comment was NOT there (you have to rely on your memory, because there is no mark that a comment was deleted, or when, on which video…). I will try to reproduce it from memory here (because I cannot find it anywhere), I’ll let the reader decide it it was spam, scam or not:


It’ not enough to name your arguments, the names have to be meaningful.
In 2023 we still have this:

  • const char * strstr ( const char * str1, const char * str2 );
    thanks cplusplus.com ! WTF is str1 and str2? And this is the 1st result on Google (I mean duckduckgo.com)
  • char *strstr(const char *haystack, const char *needle) tutorialspoint.com has it right
  • char *strstr(const char *str,const char *strSearch); so does learn.microsoft.com
  • char *strstr (const char *s1, const char *s2); geeksforgeeks.org can F*** right off
  • char *strstr( const char *str, const char *substr ); cppreference.com does it well
  • char *strstr(const char *string1, const char *string2); IBM can also go to hell
  • char *strstr(const char *s1, const char *s2); so do pubs.opengroup.org

Yay, at least they all name the arguments. Are we happy now?
Well, actually not all, this is what newlib has to say about this:

  • char *_EXFUN(strstr,(const char *, const char *)); 1 or
  • char *strstr (const char *, const char *); 2

Good luck to my fellow embedded developers!

How are junior programmers supposed to name arguments right when this is what they learn from the big guys?

And contrary to what cplusplus.com says, strstr returns a NON const pointer from 2 const pointer. Congratulation!

We are all doomed!

[1] github.com/eblot/newlib/blob/master/newlib/libc/include/string.h
github.com/32bitmicro/newlib-nano-1.0/blob/master/newlib/libc/include/string.h
[2] sourceware.org


… and I understand why YouTYube might detect the “excessive” domain name usage and a couple of links as spam, but FUCK them too for removing my educational comment without providing: 1/ any means to see the comment they have an issue with; 2/ recover a copy; 3/ appeal to restore it… Meanwhile leaving trash comment up and letting actual scams trough!

Computer Color is Broken

Well, yeah, writing good code not only requires the programmer to know how to write code or learning a programming language, but requires the understanding of physical, psychological and other processes involved interfacing the code. (For manipulating pixels understanding the creation, reception, transformation processes involved, and not just knowing math, how to average numbers. And for GUI development understanding humans…)

This raises the question if we (will) need coders, programmers at all, or only professionals who know their field and tell the computers how to write the code.

The Hidden Secrets Inside Internet The Deep Web – Documentary 2015

Ezt találtam ma. Ajánlom mindenkinek aki nem akarja a homokba dugni a fejét…


(Csak másfél óra ebből a film)

Ahogyan röviden össze tudnám foglalni:
A story about Silk Road, cryptography and drugs…
and also another story about the death of privacy, government overreach, corporate interest, game of law and death of justice. 🙁

És hogy hogy mennyire rossz úton járnak a war on drugs hadjáraton, vagy hogy az mennyire nem az állampolgárok megóvását és a közbiztonságot szolgálja.
https://youtu.be/gOHb5Jua-mE?t=1h5m9s

Samsung Galaxy keyboard Input language slide selection not working

This is the second time I run into this:
Switching input language by taping (and holding down) the the space bar and sliding it left/right does not work on Samsung Galaxy Note 2.
So I decided to write a “Note to self” post, because fixing it is not at all intuitive.

Everything in the keyboard settings is set right, the problem is not there.
The problem is with some weird interaction with accessibility services.

The sliding language selector does not work if any accessibility service is turned on.

After switching it/them off it works like a charm. Switching any of them on breaks the keyboard…

There’s definitely some bugs here, cause when a service is turned on and the Accessibility panel shows it as on, after I tap it and the service page is showed the on/off slider is in off stage. I have to turn it on and then off to actually be able to turn it off.

It sure would be great if someone fixed that.

Why Pascal is better than C

Or to be more specific, why is C bad.

I learnt Pascal before C, and Delphi before C++. So this might be just that. Meaning that my brain is damaged by Pascal 🙂

I’m also Hungarian and the sentence and phrase construction order is different than in English. And because you express your thoughts in language, it pretty much means that we learn to think in different order than humanoids brought up learning English. The order in Hungarian is from big to small. In addresses (country, city, street, number), time (year, month, day, hour, minute, seconds…), names (family name, given name), even in articles (what we want to discuss, and then the details), someone’s stuff rather then stuff of someone.
So this might also contribute to my insanity. What seems to me logical order, might be different for others.

So, Why is C driving me crazy?

There is a lot of reason for it, but for now just look at a simple example.
Lets move some memory around.

When I thing about moving, I think of “Let’s move this to somewhere”. (this, to)
And I would think when a messenger gets a delivery task to carry something, form somewhere, to somewhere that would be the order (form , to).
If I know “where from” then I can already start going that way to pick it up. That is how taxis work, they first only know where to pick up someone. That is also how the IP header is structured (Source IP Address, Destination IP Address).
It feels natural: from somewhere, to somewhere.

So when I want to move some bytes in the memory I would specify from where, to where, and how much.

And that is how Move in Pascal does it:
procedure Move ( const SourcePointer; var DestinationPointer; CopyCount : Integer ) ;

On the other hand memmove in C uses the opposite order.
void * memmove ( void * destination, const void * source, size_t num );
This just doesn’t feel right.

(Both can handle overlapping source, destination buffers, that’s why they are move and not copy.)

When you write in command line you also use source destination order (copy, cp, move, mv) [1]
PHP uses from, to order too. [2]
C#, .NET also uses source, destination order. [3]

You can find the same reversal in source and destination operand ordering in AT&T and Intel assembly formats.
Intel has dest = source order, while AT&T the opposite.
(It’s strange, I’m compelled to end my lines with a semicolon;)

Example: [4]

Intex Syntax AT&T Syntax
mov eax,[ebx]
mov eax,[ebx+3]
add eax, 4
movl (%ebx),%eax
movl 3(%ebx),%eax
addl $4, %eax

I like Intel’s syntax more. Because it resembles the assignment operator order:
eax = *ebx;
eax = *(ebx+3);
eax += 4;

And I know that it is the opposite order (dest, source) of Move, but I’m crazy like that…
But mov actually means: make this equal to that, (there is no actual moving from).

I think the order should always be this, that and here, there.
So if I call a function Move, than it should move from here to there.
But if I call a function MoveTo, then it might move to here from there.
(We could clarify by naming it MoveFrom or MoveFromTo (which sound awful), but the from, to order just seems natural to me.)

Next time I might write something about constructors. Till then you can also read my rant about arrays, and why are they suck in C, and rock in Pascal… 😉

SMM – x86 BIOS Security

Here is my Security update blog post… of this year, or decade, or ever 🙂

Most of us know viruses and even computer viruses, malwares, spywares, and use anti-virus software. Some of us even know rootkits, that run hidden from us (userspace) and sometimes from even the OS.

Do you know what your computer actually does when it boots up, and what is SMM or what the SMI Handler does? (I didn’t.)

The latest and greatest rootkits now run in System Management Mode (developed and supplied by hackers, NSA …) started straight from the BIOS. (Before your OS even has a chance to load.)

So don’t even trust your trusty Live CDs (pendrives…) to run clean.

So this is the research paper I found:
Are You Giving Firmware Attackers a Free Pass? from legbacore
Stealing encryption keys after booting into Tails Live OS Video

Other Info:
The Boot up process explained in detail [part 2]
System Management Mode
NSA implants

Tools & SW:
Copernicus (License Request)
chipsec
biosbits
hwlatdetect
Coreboot

Your Phones are not better either…
Using NAND Flash Bad Block Table to Hide stuff