Blame HACKING

Packit Service 88ab54
============
Packit Service 88ab54
Coding Style
Packit Service 88ab54
============
Packit Service 88ab54
Packit Service 88ab54
- Use explicit ``!= NULL``, ``!= 0``, etc. This makes code easier to read
Packit Service 88ab54
  and remove warnings on some platform. Don't forget SPACES before and
Packit Service 88ab54
  after the comparison operator.
Packit Service 88ab54
Packit Service 88ab54
  Examples:
Packit Service 88ab54
    BAD:
Packit Service 88ab54
            ``if (a)``
Packit Service 88ab54
    BAD:
Packit Service 88ab54
            ``if (a!=NULL)``
Packit Service 88ab54
    GOOD:
Packit Service 88ab54
            ``if (a != NULL)``
Packit Service 88ab54
    GOOD:
Packit Service 88ab54
            ``if (a != 0)``
Packit Service 88ab54
Packit Service 88ab54
- Put figure brackets ``{}`` even if you have only one operator
Packit Service 88ab54
  in ``if``, ``for``, etc. This also makes code easier to read and 
Packit Service 88ab54
  saves a lot of time when you need to quickly change something. 
Packit Service 88ab54
Packit Service 88ab54
  Examples:
Packit Service 88ab54
    BAD:
Packit Service 88ab54
      .. line-block::
Packit Service 88ab54
Packit Service 88ab54
         if (a != NULL)
Packit Service 88ab54
           message(G_LOG_LEVEL_MESSAGE, "Ko");
Packit Service 88ab54
    GOOD:
Packit Service 88ab54
      .. line-block::
Packit Service 88ab54
Packit Service 88ab54
         if (a != NULL) {
Packit Service 88ab54
           message(G_LOG_LEVEL_MESSAGE, "Ok");
Packit Service 88ab54
         }
Packit Service 88ab54
Packit Service 88ab54
- Put SPACES before the opening round bracket and after the closing round
Packit Service 88ab54
  bracket with ``if``, ``for``, ``switch``, ``while``, etc. One more time,
Packit Service 88ab54
  it improves the readability of the code.
Packit Service 88ab54
Packit Service 88ab54
  Examples:
Packit Service 88ab54
    BAD:
Packit Service 88ab54
      .. line-block::
Packit Service 88ab54
Packit Service 88ab54
         if(a != NULL){
Packit Service 88ab54
           message(G_LOG_LEVEL_MESSAGE, "Ko");
Packit Service 88ab54
         }
Packit Service 88ab54
    GOOD:
Packit Service 88ab54
      .. line-block::
Packit Service 88ab54
Packit Service 88ab54
         if (a != NULL) {
Packit Service 88ab54
           message(G_LOG_LEVEL_MESSAGE, "Ok");
Packit Service 88ab54
         }
Packit Service 88ab54
Packit Service 88ab54
- Limit line length to at most 100 characters.
Packit Service 88ab54
Packit Service 88ab54
- Check for memory leaks.
Packit Service 88ab54
  I recommend valgrind (http://valgrind.kde.org) utility with options:
Packit Service 88ab54
    --leak-check=yes
Packit Service 88ab54
    --show-reachable=yes
Packit Service 88ab54
    --num-callers=32
Packit Service 88ab54
    --suppressions=tests/valgrind/openssl.supp
Packit Service 88ab54
Packit Service 88ab54
Packit Service 88ab54
Packit Service 88ab54
GNU Emacs
Packit Service 88ab54
=========
Packit Service 88ab54
Packit Service 88ab54
::
Packit Service 88ab54
Packit Service 88ab54
  (defun lasso-c-mode ()
Packit Service 88ab54
    "C mode with adjusted defaults for use with Lasso."
Packit Service 88ab54
    (interactive)
Packit Service 88ab54
    (c-mode)
Packit Service 88ab54
    (c-set-style "K&R")
Packit Service 88ab54
    (setq tab-width 8)
Packit Service 88ab54
    (setq indent-tabs-mode t)
Packit Service 88ab54
    (setq c-basic-offset 8))
Packit Service 88ab54
Packit Service 88ab54
This will define the M-x lasso-c-mode command.  It can be switched on
Packit Service 88ab54
automatically in a given directory::
Packit Service 88ab54
Packit Service 88ab54
  (setq auto-mode-alist (cons '("/usr/src/lasso.*/.*\\.[ch]$" .  lasso-c-mode)
Packit Service 88ab54
	auto-mode-alist))
Packit Service 88ab54