Project

General

Profile

Bug #1200

various modules declare static functions within function bodies

Added by Rich Lowe over 9 years ago. Updated over 9 years ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
kernel
Start date:
2011-07-11
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

It is, apparently, non-sensical to place a static function prototype within the body of a function, though Studio and GCC have supported it.

They should be pulled up to file scope.

#1

Updated by Alan Coopersmith over 9 years ago

I believe placing function prototypes in the body of functions is technically legal C, but strongly discouraged as bad style, as it leads to prototypes being out of sync in different files. gcc similarly warns about non-static functions for which prototypes are not found from a common header file to avoid issues from prototype proliferation in calling sources.

#2

Updated by Rich Lowe over 9 years ago

Putting prototypes in function bodies is certainly tasteless, but declaring them static is bogus: if the compiler supports nested functions as an extension, 'static' and it being declared within a function will specify conflicting scope; and possibly bogus in general -- I'm not certain what the standards say about the scope of a prototype declared within a function body, regardless of the nested-functions extension.

#3

Updated by Rich Lowe over 9 years ago

  • Status changed from In Progress to Resolved
  • % Done changed from 80 to 100

Resolved in r13404 commit:4a1868d4ae91

Also available in: Atom PDF