Permalink
Browse files

Fixed some errors pointed out by codespell and cppcheck

  • Loading branch information...
1 parent a425bc5 commit 18ed3bc44dcd9358423f4f0f11a365885a668941 @haakonnessjoen committed Oct 15, 2016
Showing with 12 additions and 4 deletions.
  1. +1 −1 src/autologin.c
  2. +10 −2 src/mactelnetd.c
  3. +1 −1 src/mndp.c
View
@@ -78,7 +78,7 @@ int autologin_readfile(char *configfile) {
file_to_read = tilde_to_path(configfile);
fp = fopen(file_to_read, "r");
- if (fp <= 0) {
+ if (!fp) {
if (strcmp(configfile, AUTOLOGIN_PATH) == 0) {
/* Silent ignore? */
} else {
View
@@ -479,9 +479,17 @@ static void user_login(struct mt_connection *curconn, struct mt_mactelnet_hdr *p
struct stat sb;
struct passwd *user = (struct passwd *)malloc(sizeof(struct passwd));
struct passwd *tmpuser=user;
- char *buffer = malloc(1024);
+ char *buffer;
- if (user == NULL || buffer == NULL) {
+ if (user == NULL) {
+ syslog(LOG_CRIT, _("(%d) Error allocating memory."), curconn->seskey);
+ /*_ Please include both \r and \n in translation, this is needed for the terminal emulator. */
+ abort_connection(curconn, pkthdr, _("System error, out of memory\r\n"));
+ return;
+ }
+
+ buffer = (char *)malloc(1024);
+ if (buffer == NULL) {
syslog(LOG_CRIT, _("(%d) Error allocating memory."), curconn->seskey);
/*_ Please include both \r and \n in translation, this is needed for the terminal emulator. */
abort_connection(curconn, pkthdr, _("System error, out of memory\r\n"));
View
@@ -128,7 +128,7 @@ int mndp(int timeout, int batch_mode) {
/* Wait for a UDP packet */
result = recvfrom(sock, buff, sizeof(buff), 0, (struct sockaddr *)&addr, &addrlen);
if (result < 0) {
- fprintf(stderr, _("An error occured. aborting\n"));
+ fprintf(stderr, _("An error occurred. aborting\n"));
exit(1);
}

0 comments on commit 18ed3bc

Please sign in to comment.