General Important Points

  1. Write in a clear and consistent coding style. Ensure Code is well formatted with hard tab for whitespace. Match the spacing for each curly braces.
  2. Code should be self-documenting. Variables should be sensibly named, function names descriptive of their purpose. Reserve comments for places where clarification is valuable
  3. If you have a long piece of code and it's hard to tell what it does, consider splitting it up into several functions whose names will describe what's going on.
  4. Keep your headers clean. Put the absolute minimum required in your headers for your interface to be used (Only declarations). As much possible put the function definitions in source (cpp ) file.
  5. Don't expose your classes' private parts. Keep as much of your classes private as possible. All data members should be private; mark them as such by using a leading ‘m’ to differentiate between class variables to local variables: int mSomeVariable; you can then write the getter/setter functions for this variable as int GetSomeVariable() const; and int& SetSomeVariable( int value );. Avoid friend functions.
  6. Use const wherever possible. All member functions that do not modify their object should be const. If your function takes a reference to an object and does not modify that object, you should be passing a const reference.
  7. Write portable code. Don't use compiler-specific features or depend on long or unsigned types being a particular size. Prefer to use size_t for array indexing, especially when dealing with the STL.
  8. Don't leak memory. Every heap allocation using new should have a corresponding delete. Use shared_ptr as much possible to avoid risk of memory leak.
  9. Avoid repeating the same expression or method call - compiler might be smart enough to optimize, but better to use a local variable to collect results that are used in more than one place
  10. Avoid copy/pasted code snippets, or repeated code.  Usually this points to possible refactoring which will result in simpler, more maintainable code.
  11. Follow the Boy Scout rule - Always check a module in cleaner than when you checked it out
  12. Check and respect compilation warnings!  A strict compiler is your friend.
  13. Please use hard tabs, 4 spaces wide.

Classes in C++

Header Dependencies

#ifndef __AAMP_GLOBALCONFIG_H__

#define __AAMP_GLOBALCONFIG_H__

..

#endif

Other

Use proper printf format specifiers, i.e.

specifier

type

%d

int
%uunsigned int
%l long
%luunsigned long
%lllong long
%ullunsigned long long
%ffloat
%lfdouble
%zusize_t

PRIu64

for uint64_t


Steps for using Coverity tool

1.     Procure access to Coverity portal
·       Coverity Portal url: https://coverity-wc-a1.cable.comcast.com/login/login.htm
·       Credentials : NTID and password
·       Raise RDKSVREQ ticket for access permission.
·       Sample Request: https://ccp.sys.comcast.net/browse/RDKSVREQ-21961
·       Please note that it takes 24 hrs for the activation to reflect in the Coverity portal
2.     Create gerrit link for the latest code check in
·       Complete the code changes in the dev_sprint.
·       Obtain the patch using the command
--> git format-patch -1
·       Raise  the gerrit , along with the bb file in the required the sprint
              Similar to this -> https://gerrit.teamccp.com/#/c/433297/
3.     Generate Jenkins build with the Gerrit patch set generated as part of step 2 and USE_COVERITY flag checked
4.     Once the build is successful, get the 'snapshot ID ' from the Jenkins build console logs. Just search for the string 'snapshot ID ' in the Console Output -> full log for the Jenkins build.
5.     Login to the coverity portal and navigate to Snapshots->All in project
6.     Will get a list of snapshotid's , select the snapshot id got from build, navigate to the aamp component and check for the new defects that were observed by checking the new defects and the date
7.     Will be listed with the new set of defects that were observed, check whether there is any defects new raised from the current file changes.
8.     Once the bugs identified are fixed, use the same procedure to confirm that the Coverity scan finds the issues fixed.

Doxygen-Friendly Coding Conventions

(following courtesy of Deepan, under review)

Kindly go through the document to understand how to do Doxygen coding convention

AAMP Logging Guidelines

Following log levels are supported in AAMP logging . Need to use respective log macro needed for each level 

While tuning, by default log level is set to (more noisy) INFO level.  Once a given tune is compete, default log level is changed to WARN until end of the playback.  This is compromised to avoid log flooding during steady state.

Log Level

Macro to be used 

Description

ERROR

AAMPLOG_ERR

Log level to print "error" logs.  This is intended to print things that should never (logically) happen, severe problems worth raising tickets.
INFO

AAMPLOG_INFO

Log level to print debug / informative messages . INFO level logs are normally available while tuning, but disabled during playback.  This level logs are good for quick issue triage. 

Developer can force INFO level logging to always be printed using aamp.cfg "info"

TRACE

AAMPLOG_TRACE

Log level to print trace messages . Used for triaging/development purpose only. Never gets logged in production. Trace level logging can be enabled with configuration 
WARN

AAMPLOG_WARN

Log level to print warning messages and for any logs with critical information during regular flow. This log level will be printed always.  Warnings should be used for exceptions that player is able to handle robustly, or for environmental problems that don't reflect a client issue.

Process Notes