The code
Embedded Linux C. It compiles. There are 4 real bugs in it: the kind that pass a bench test and fail in the field.
int gps_open(void)
{
int fd = open("/dev/ttyS2", O_RDWR);
struct termios t;
tcgetattr(fd, &t);
cfsetispeed(&t, B9600);
cfsetospeed(&t, B9600);
tcsetattr(fd, TCSANOW, &t);
return fd;
}
int gps_read_sentence(int fd, char *out, size_t cap)
{
ssize_t n = read(fd, out, cap);
if (n <= 0) return -1;
out[n] = '\0';
return (int)n;
}What an interviewer expects
- Point to each line you'd stop in a code review.
- Say what actually breaks: the failure mode, not just the rule it violates.
- Fix it, then defend the fix when asked the follow-up.
The bugs, reference fixes and the follow-up question are in the practice app, after you've tried it.
Companies that test this
Matched on the skills each company's embedded roles emphasise.
AptivAutomotive supplier · India hiring: MediumCapgemini EngineeringEngineering services · India hiring: HighCyientEngineering services · India hiring: MediumInfosys Engineering ServicesEngineering services · India hiring: HighL&T Technology ServicesEngineering services · India hiring: HighMarvellChipmaker · India hiring: MediumMercedes-Benz R&D IndiaAutomotive OEM R&D · India hiring: HighSchneider ElectricIndustrial · India hiring: High
Related challenges
Character driver read()Embedded Linux · Medium · 3 bugs · ~7 minPing diagnostic on a Linux gatewayEmbedded Linux · Medium · 3 bugs · ~6 minGPIO through /dev/memEmbedded Linux · Medium · 3 bugs · ~6 minTouch driver interrupt handlerEmbedded Linux · Hard · 3 bugs · ~7 minADC over spidevEmbedded Linux · Medium · 3 bugs · ~6 min
Flag the lines, say what breaks, then fix it and build it with clang in your browser.
Find the bugs