Skip to content

Commit ce3885f

Browse files
committed
Adapted yes.c and vpfmt.c to ANSI C
1 parent 4373c43 commit ce3885f

2 files changed

Lines changed: 8 additions & 5 deletions

File tree

libcommon/vpfmt.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include "pfmt.h"
1212

13+
1314
extern char *pfmt_label__;
1415

1516
/*
@@ -42,7 +43,7 @@ vpfmt(FILE *stream, long flags, const char *fmt, va_list ap)
4243
{
4344
int n = 0;
4445
const char *severity = NULL;
45-
char sevbuf[25];
46+
char sevbuf[25];
4647

4748
if ((flags&MM_NOSTD) == 0) {
4849
if (flags & MM_ACTION)
@@ -61,7 +62,9 @@ vpfmt(FILE *stream, long flags, const char *fmt, va_list ap)
6162
severity = "ERROR";
6263
break;
6364
default:
64-
snprintf(sevbuf, sizeof sevbuf, "SEV=%ld", flags&0377);
65+
/* snprintf is not needed here since we know
66+
`flags & 0xFF` can't take more than 3 chars */
67+
sprintf(sevbuf, "SEV=%ld", flags & 0xFF);
6568
severity = sevbuf;
6669
}
6770
if (pfmt_label__)

yes/yes.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
#include <stdio.h>
1414

1515
int main(int argc, char **argv) {
16-
// Defining it before looping for the comparison to be executed a single
17-
// time
16+
/* Defining it before looping for the comparison to be executed a single
17+
time */
1818
const char *to_print = argc > 1 ? argv[1] : "y";
1919

2020
while (puts(to_print) != EOF);
2121

22-
// Always return error since it can only stop if it couldn't write
22+
/* Always return error since it can only stop if it couldn't write */
2323
return 1;
2424
}

0 commit comments

Comments
 (0)