<추가 강좌 팁 요청> splint 사용하기.

antz의 이미지

사용한지 얼마안되서 아는게 거의 없지만,
우선 올립니다. :roll:

splint는 c 코드를 컴파일 전에 미리 에러검출 해주는 프로그램입니다.

제가 찾아 본것은 splint와 clint 인데.
clint는 오랫동안 업데이트를 안한것 같더군요.
더 좋은 툴이 있는지 모르겠습니다.

splint는 Secure Programming Lint 라고 합니다.

기본적으로 unused 변수, buffer overflower warning등을 보여줍니다.
보통 너무 많은 메세지 때문에 초반부터 질리시는 분들이 많습니다만,
옵션으로 warning을 줄일 수 있습니다.

간단한 사용법은

소스가 있는 디렉토리에 .splintrc 를 만들고,

다음과 같이 실행합니다.

Quote:
$ splint [source.c|.h]

.splintrc 는 splint 의 옵션을 그대로 적습니다.
(실행때 직접 옵션을 줘도 되지만, 너무 귀찮고 힘들겁니다.)
환경설정 파일의 예입니다.

Quote:
$ cat .splintrc
-I../include/ -warnposix -usevarargs -likelybool

간단히 설명하면, include 디렉토리에 "../include/ " 추가하고,
posix에 대한 워닝이 너무많아서 posix 워닝을 제거했습니다.
(옵션에서 +는 추가이고, -는 제거입니다.)

-usevarargs "varargs.h" 에대한 워닝 제거,
-likelybool "BOOL" 사용에 대한 워닝 제거.

실행결과의 예입니다.

Quote:
Splint 3.1.1 --- 29 Oct 2003

Spec file not found: 2.lcl
Cannot open file: 2.c
cindexdata.c: (in function main)
cindexdata.c:128:9: Unrecognized identifier: chkInit
Identifier used in code has not been declared. (Use -unrecog to inhibit
warning)
cindexdata.c:157:62: Format argument 1 to fprintf (%x) expects unsigned int
gets int: optopt
To ignore signs in type comparisons use +ignoresigns
cindexdata.c:157:54: Corresponding format code
cindexdata.c:168:9: Test expression for if not boolean, type BOOL:
b_isBackground
Test expression type is not boolean or int. (Use -predboolint to inhibit
warning)
cindexdata.c:169:9: Unrecognized identifier: SIGHUP
cindexdata.c:169:2: Return value (type [function (int) returns void]) ignored:

좀 더 잘 사용하실줄 아시는 분이나,
더 좋은 툴을 알고 계신분은 답글 부탁드립니다.

감사합니다.

Forums: 
hidRomeo의 이미지

mollla wrote:
사용한지 얼마안되서 아는게 거의 없지만,
우선 올립니다. :roll:

splint는 c 코드를 컴파일 전에 미리 에러검출 해주는 프로그램입니다.

제가 찾아 본것은 splint와 clint 인데.
clint는 오랫동안 업데이트를 안한것 같더군요.
더 좋은 툴이 있는지 모르겠습니다.

splint는 Secure Programming Lint 라고 합니다.

기본적으로 unused 변수, buffer overflower warning등을 보여줍니다.
보통 너무 많은 메세지 때문에 초반부터 질리시는 분들이 많습니다만,
옵션으로 warning을 줄일 수 있습니다.

간단한 사용법은

소스가 있는 디렉토리에 .splintrc 를 만들고,

다음과 같이 실행합니다.

Quote:
$ splint [source.c|.h]

.splintrc 는 splint 의 옵션을 그대로 적습니다.
(실행때 직접 옵션을 줘도 되지만, 너무 귀찮고 힘들겁니다.)
환경설정 파일의 예입니다.

Quote:
$ cat .splintrc
-I../include/ -warnposix -usevarargs -likelybool

간단히 설명하면, include 디렉토리에 "../include/ " 추가하고,
posix에 대한 워닝이 너무많아서 posix 워닝을 제거했습니다.
(옵션에서 +는 추가이고, -는 제거입니다.)

-usevarargs "varargs.h" 에대한 워닝 제거,
-likelybool "BOOL" 사용에 대한 워닝 제거.

실행결과의 예입니다.

Quote:
Splint 3.1.1 --- 29 Oct 2003

Spec file not found: 2.lcl
Cannot open file: 2.c
cindexdata.c: (in function main)
cindexdata.c:128:9: Unrecognized identifier: chkInit
Identifier used in code has not been declared. (Use -unrecog to inhibit
warning)
cindexdata.c:157:62: Format argument 1 to fprintf (%x) expects unsigned int
gets int: optopt
To ignore signs in type comparisons use +ignoresigns
cindexdata.c:157:54: Corresponding format code
cindexdata.c:168:9: Test expression for if not boolean, type BOOL:
b_isBackground
Test expression type is not boolean or int. (Use -predboolint to inhibit
warning)
cindexdata.c:169:9: Unrecognized identifier: SIGHUP
cindexdata.c:169:2: Return value (type [function (int) returns void]) ignored:

좀 더 잘 사용하실줄 아시는 분이나,
더 좋은 툴을 알고 계신분은 답글 부탁드립니다.

감사합니다.

(Ф_Ф) 언제까지나 즐거울 수 있도록...

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.